higty / higlabo

HigLabo library provide 1.AI client library(OpenAI, Anthoripic, Groq) 2.Object Mapper(fastest in the world) 3.DbSharp(DAL generator) 4.Other.(Mail, Ftp, Utility...etc)
182 stars 82 forks source link

Assistants API with Azure OpenAI - Resource not found #82

Closed krishnankuppaswamy closed 6 months ago

krishnankuppaswamy commented 7 months ago

Hi @higty - love this library.

I had used the assistants API via direct OpenAI subscription.

I now have access to Azure OpenAI subscription. With the AzureSettings class, created the OpenAIClient as per the documentation. Set the API Version too. However, unable to get the Assistatns API working.

Please note:

Request URL

Payload

{
    "tools": [],
    "name": "Math Tutor",
    "instructions": "You are a personal math tutor. Answer questions briefly, in a sentence or less.",
    "model": "gpt-4-1106-preview",
    "file_ids": []
}

AssistantCreateParameter class has a GetApiPath() set to /assistants. Should it be /openai/assistants instead?

No luck.

Please confirm if the library was tested with the Azure OpenAI?

Some guidance over this query would be helpful. Appreciate your time.

krishnankuppaswamy commented 7 months ago

Hi @higty - love this library.

I had used the assistants API via direct OpenAI subscription.

  • Everything works πŸ‘

I now have access to Azure OpenAI subscription. With the AzureSettings class, created the OpenAIClient as per the documentation. Set the API Version too. However, unable to get the Assistatns API working.

  • I get Resource not found exception.

Please note:

  • I can make use of the Azure OpenAI studio and create assistant and run that on the web portal. - works
  • I created a postman request, and able to create assistant. - works

Request URL

Payload

{
    "tools": [],
    "name": "Math Tutor",
    "instructions": "You are a personal math tutor. Answer questions briefly, in a sentence or less.",
    "model": "gpt-4-1106-preview",
    "file_ids": []
}

AssistantCreateParameter class has a GetApiPath() set to /assistants. Should it be /openai/assistants instead?

  • I tried setting the endpointUri to - ending with /
  • I tried setting the endpointUri to - ending with /openai/ as well

No luck.

Please confirm if the library was tested with the Azure OpenAI?

Some guidance over this query would be helpful. Appreciate your time.

Hi @higty - please find the additional details.

It appears like the following is extra information in the URL

How to work with the library in this case?

krishnankuppaswamy commented 7 months ago

Hi @higty - love this library. I had used the assistants API via direct OpenAI subscription.

  • Everything works πŸ‘

I now have access to Azure OpenAI subscription. With the AzureSettings class, created the OpenAIClient as per the documentation. Set the API Version too. However, unable to get the Assistatns API working.

  • I get Resource not found exception.

Please note:

  • I can make use of the Azure OpenAI studio and create assistant and run that on the web portal. - works
  • I created a postman request, and able to create assistant. - works

Request URL

Payload

{
    "tools": [],
    "name": "Math Tutor",
    "instructions": "You are a personal math tutor. Answer questions briefly, in a sentence or less.",
    "model": "gpt-4-1106-preview",
    "file_ids": []
}

AssistantCreateParameter class has a GetApiPath() set to /assistants. Should it be /openai/assistants instead?

  • I tried setting the endpointUri to - ending with /
  • I tried setting the endpointUri to - ending with /openai/ as well

No luck. Please confirm if the library was tested with the Azure OpenAI? Some guidance over this query would be helpful. Appreciate your time.

Hi @higty - please find the additional details.

It appears like the following is extra information in the URL

  • deployments/gpt-4-1106-preview/

How to work with the library in this case?

@higty Is there a way to set up the ApiUrl or any other logic that can be setup for assistants?

https://github.com/higty/higlabo/blob/master/Net8/HigLabo.OpenAI/Core/OpenAIClient.cs#L43

krishnankuppaswamy commented 7 months ago

Hi @higty - Unfortunately I am moving towards Azure OpenAI SDK while I haven't heard from you.

I will be watching for the changes to the repo though. All the best!

higty commented 6 months ago

Hi. Sorry late reply. Thank you for your comment. It may be bug. I'll investigate to it.

higty commented 6 months ago

Actually, I don't test for AzureOpenAI. I assumed that all endpoint must be same as OpenAI. But from your comment, it seems different. I'll investigate it.

higty commented 6 months ago

I changed ApiUrl logic based on your information. If you set DeploymentId is null or empty, ApiUrl will return "https://myapp-openai-00001.openai.azure.com/openai". So, it may be work.

And yesterday, I added assistant streming API feature. Now you can consume Assistant API response like ChatCompletion API endpoint. This improve UX for your user.

I'm looking forward to hear this works correctly as you expected without bug.

regarad.

krishnankuppaswamy commented 6 months ago

I changed ApiUrl logic based on your information. If you set DeploymentId is null or empty, ApiUrl will return "https://myapp-openai-00001.openai.azure.com/openai". So, it may be work.

And yesterday, I added assistant streming API feature. Now you can consume Assistant API response like ChatCompletion API endpoint. This improve UX for your user.

I'm looking forward to hear this works correctly as you expected without bug.

regarad.

Thanks @higty 😊

I will review this later today or tomorrow and provide you an update.

Thanks for the support.

higty commented 6 months ago

I'll support you😊 I can't wait that all works great and help your work!

higty commented 6 months ago

It may work based on provided information. I'll close this issue. If it does not work, please reopen issue.

krishnankuppaswamy commented 6 months ago

Sure, @higty. Thanks

higty commented 5 months ago

I confirmed all works on AzureOpenAI.

krishnankuppaswamy commented 5 months ago

Thanks, @higty. I will review this with the updated library.