JZO001 / Forge.OpenAI

OpenAI API client library for .NET. I was developed it for for public use and it is free.
MIT License
36 stars 14 forks source link

Support for Azure Open AI #5

Open robertstewartnz opened 9 months ago

robertstewartnz commented 9 months ago

Hi there,

I'm attempting to swap over to Azure Open AI and have come up against two problems.

1) the example here seems incomplete. It appears we have to provide the BaseAddress and AzureApiVersion. Is this correct?

2) A bigger issue seems to be how you are handling AuthenticationInfo

public AuthenticationInfo(string apiKey)
        {
            if (string.IsNullOrWhiteSpace(apiKey)) throw new ArgumentNullException(nameof(apiKey));

            if (!apiKey.Contains("sk-"))
            {
                throw new ArgumentException($"{apiKey} parameter must start with 'sk-'");
            }

            ApiKey = apiKey;
        }

As far as I'm aware Azure does not prefix their API keys with sk-. Without adding the "sk-" I'm getting argument exception and if I add "sk-" to my Azure key I'm getting a 404. Are you able to provide some guidance.

Cheers -Rob

JZO001 commented 9 months ago

Hello, Looks like the protocol changed in the last months as always. I will give it a look.

JZO001 commented 8 months ago

Hi there,

I'm attempting to swap over to Azure Open AI and have come up against two problems.

  1. the example here seems incomplete. It appears we have to provide the BaseAddress and AzureApiVersion. Is this correct?
  2. A bigger issue seems to be how you are handling AuthenticationInfo
public AuthenticationInfo(string apiKey)
        {
            if (string.IsNullOrWhiteSpace(apiKey)) throw new ArgumentNullException(nameof(apiKey));

            if (!apiKey.Contains("sk-"))
            {
                throw new ArgumentException($"{apiKey} parameter must start with 'sk-'");
            }

            ApiKey = apiKey;
        }

As far as I'm aware Azure does not prefix their API keys with sk-. Without adding the "sk-" I'm getting argument exception and if I add "sk-" to my Azure key I'm getting a 404. Are you able to provide some guidance.

Cheers -Rob

Please have a look to the latest release