BotSharp/src/Infrastructure/BotSharp.Core/Infrastructures/CompletionProvider.cs
2023-09-14 11:42:48 -05:00

20 lines
562 B
C#

using BotSharp.Abstraction.MLTasks;
namespace BotSharp.Core.Infrastructures;
public class CompletionProvider
{
public static IChatCompletion GetChatCompletion(IServiceProvider services, string? model = null)
{
var completions = services.GetServices<IChatCompletion>();
var state = services.GetRequiredService<IConversationStateService>();
if (model == null)
{
model = state.GetState("model", "gpt-3.5-turbo");
}
return completions.FirstOrDefault(x => x.ModelName == model);
}
}