Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure OpenAI issue #64

Open
davidd00 opened this issue Mar 7, 2023 · 8 comments
Open

Azure OpenAI issue #64

davidd00 opened this issue Mar 7, 2023 · 8 comments

Comments

@davidd00
Copy link

davidd00 commented Mar 7, 2023

I'm trying to use this library with an Azure OpenIA resource.
I'm using the example in the readme: OpenAIAPI api = OpenAIAPI.ForAzure("YourResourceName", "deploymentId", "api-key");, but Url created seems to be wrong.

OpenAIAPI api object initialization:
OpenAIAPI api = OpenAIAPI.ForAzure("opeanai-resource", "deployedEngine", "apikey");
CreatedUrl:
https://opeanai-resource.openai.azure.com/openai/deployments/deployedEngine)/{1}?api-version={0}

It adds a clos parenthesis to the resource engine, so I get this error: The API deployment for the resource does not exist.

I guess the ApiVersion {0} and the completion {1} are added when doing the requests, but are not showed in the Url

@OkGoDoIt
Copy link
Owner

OkGoDoIt commented Mar 9, 2023

I have fixed the extra parenthesis in the generated URL, sorry about that. Beyond that, I don't have any insight into what those values should be or how to test it. Microsoft denied my application to access the Azure OpenAI endpoint, so I'm just guessing based on documentation. Can you give me an example of a correct HTTP request that works for you, including all headers except authorization? That way to can try to make sure this SDK works similarly.

@realchrisparker
Copy link

I have access to Azure OpenAI. I will look into this today and provide feedback. I hope I can be of help.

@davidd00
Copy link
Author

Sorry, I missed the answer to the issue. I'll try to test it today too.
Thanks!

@AndrewGretton
Copy link

Just wanted to add to this thread that - it's all working fine for me, with an Azure OpenAI deployment. The parenthesis fix was all that was needed.

@davidd00
Copy link
Author

Just wanted to add to this thread that - it's all working fine for me, with an Azure OpenAI deployment. The parenthesis fix was all that was needed.

I confirm that the parenthesis issue is fixed and it's working fine now 👍
Thanks!

@jiangweifang
Copy link

jiangweifang commented Mar 22, 2023

I have fixed the extra parenthesis in the generated URL, sorry about that. Beyond that, I don't have any insight into what those values should be or how to test it. Microsoft denied my application to access the Azure OpenAI endpoint, so I'm just guessing based on documentation. Can you give me an example of a correct HTTP request that works for you, including all headers except authorization? That way to can try to make sure this SDK works similarly.

image

This's the console of Azure OpenAI. The blue part is 'YourResourceName' and the red part is 'deploymentId'.

Response:
image
image

Hope this helps you.

And don't worry. Your SDK is perfectly usable.
Thanks.

@realchrisparker
Copy link

This works for me.

HttpRequestMessage request = new()
{
Method = HttpMethod.Post,
RequestUri = new Uri( $"https://{resourceName}.openai.azure.com/openai/deployments/{deploymentName}/completions?api-version=2022-12-01" ),
Content = new StringContent( completionMessage.ToString(), Encoding.UTF8, "application/json" ),
};
request.Headers.Clear();
request.Headers.Accept.Add( new MediaTypeWithQualityHeaderValue( "application/json" ) );
request.Headers.Add( "api-key", apiKey );

            var response = await _httpClient.SendAsync( request );

{
"prompt": "",
"temperature": 1,
"top_p": 0.5,
"frequency_penalty": 0,
"presence_penalty": 0,
"max_tokens": 100,
"best_of": 1,
"stop": null
}

@nicogis
Copy link

nicogis commented May 8, 2023

I have tried with gpt-35-turbo (version 0301) and 2023-03-15-preview and it's ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants