BotSharp/src/Infrastructure/BotSharp.Core/Infrastructures/CompletionProvider.cs

20 lines
562 B
C#
Raw Normal View History

2023-09-09 15:37:38 +00:00
using BotSharp.Abstraction.MLTasks;
namespace BotSharp.Core.Infrastructures;
public class CompletionProvider
{
2023-09-14 16:42:48 +00:00
public static IChatCompletion GetChatCompletion(IServiceProvider services, string? model = null)
2023-09-09 15:37:38 +00:00
{
var completions = services.GetServices<IChatCompletion>();
2023-09-14 16:42:48 +00:00
2023-09-14 01:41:51 +00:00
var state = services.GetRequiredService<IConversationStateService>();
2023-09-14 16:42:48 +00:00
if (model == null)
{
model = state.GetState("model", "gpt-3.5-turbo");
}
2023-09-14 01:41:51 +00:00
return completions.FirstOrDefault(x => x.ModelName == model);
2023-09-09 15:37:38 +00:00
}
}