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

OpenAI-DotNet 8.4.0 #375

Merged
merged 11 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion OpenAI-DotNet/Authentication/OpenAIClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace OpenAI
/// </summary>
public sealed class OpenAIClientSettings
{
internal const string WS = "ws://";
internal const string WSS = "wss://";
internal const string Http = "http://";
internal const string Https = "https://";
internal const string OpenAIDomain = "api.openai.com";
internal const string DefaultOpenAIApiVersion = "v1";
Expand All @@ -26,6 +29,7 @@ public OpenAIClientSettings()
DeploymentId = string.Empty;
BaseRequest = $"/{ApiVersion}/";
BaseRequestUrlFormat = $"{Https}{ResourceName}{BaseRequest}{{0}}";
BaseWebSocketUrlFormat = $"{WSS}{ResourceName}{BaseRequest}{{0}}";
UseOAuthAuthentication = true;
}

Expand All @@ -52,11 +56,16 @@ public OpenAIClientSettings(string domain, string apiVersion = DefaultOpenAIApiV
apiVersion = DefaultOpenAIApiVersion;
}

ResourceName = domain.Contains("http") ? domain : $"{Https}{domain}";
ResourceName = domain.Contains(Http)
? domain
: $"{Https}{domain}";
ApiVersion = apiVersion;
DeploymentId = string.Empty;
BaseRequest = $"/{ApiVersion}/";
BaseRequestUrlFormat = $"{ResourceName}{BaseRequest}{{0}}";
BaseWebSocketUrlFormat = ResourceName.Contains(Https)
? $"{WSS}{ResourceName}{BaseRequest}{{0}}"
: $"{WS}{ResourceName}{BaseRequest}{{0}}";
UseOAuthAuthentication = true;
}

Expand Down Expand Up @@ -99,6 +108,7 @@ public OpenAIClientSettings(string resourceName, string deploymentId, string api
ApiVersion = apiVersion;
BaseRequest = "/openai/";
BaseRequestUrlFormat = $"{Https}{ResourceName}.{AzureOpenAIDomain}{BaseRequest}{{0}}";
BaseWebSocketUrlFormat = $"{WSS}{ResourceName}.{AzureOpenAIDomain}{BaseRequest}{{0}}";
defaultQueryParameters.Add("api-version", ApiVersion);
UseOAuthAuthentication = useActiveDirectoryAuthentication;
}
Expand All @@ -113,6 +123,8 @@ public OpenAIClientSettings(string resourceName, string deploymentId, string api

internal string BaseRequestUrlFormat { get; }

internal string BaseWebSocketUrlFormat { get; }

internal bool UseOAuthAuthentication { get; }

[Obsolete("Use IsAzureOpenAI")]
Expand Down
Loading