Skip to content

Commit

Permalink
Set missing defaults for OpenAI #120
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva committed Oct 16, 2023
1 parent 2478d6b commit f778fce
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/ChatGptNet/ChatGptServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,18 @@ private static IChatGptBuilder AddChatGptCore(IServiceCollection services)

private static void SetMissingDefaults(ChatGptOptionsBuilder options)
{
// If the provider is OpenAI and no default model has been specified, uses gpt-3.5-turbo by default.
if (options.ServiceConfiguration is OpenAIChatGptServiceConfiguration && string.IsNullOrWhiteSpace(options.DefaultModel))
if (options.ServiceConfiguration is OpenAIChatGptServiceConfiguration)
{
options.DefaultModel = OpenAIChatGptModels.Gpt35Turbo;
options.DefaultEmbeddingModel = OpenAIEmbeddingModels.TextEmbeddingAda002;
// If the provider is OpenAI and some default models are not specified, use the default ones.
if (string.IsNullOrWhiteSpace(options.DefaultModel))
{
options.DefaultModel = OpenAIChatGptModels.Gpt35Turbo;
}

if (string.IsNullOrWhiteSpace(options.DefaultEmbeddingModel))
{
options.DefaultEmbeddingModel = OpenAIEmbeddingModels.TextEmbeddingAda002;
}
}
}
}

0 comments on commit f778fce

Please sign in to comment.