2023-09-09 15:37:38 +00:00
|
|
|
using BotSharp.Abstraction.MLTasks;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Infrastructures;
|
|
|
|
|
|
|
|
|
|
public class CompletionProvider
|
|
|
|
|
{
|
2023-09-18 08:35:02 +00:00
|
|
|
public static IChatCompletion GetChatCompletion(IServiceProvider services, string? provider = 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-18 08:35:02 +00:00
|
|
|
if (provider == null)
|
2023-09-14 16:42:48 +00:00
|
|
|
{
|
2023-09-18 08:35:02 +00:00
|
|
|
provider = state.GetState("provider", "azure-gpt-3.5");
|
2023-09-14 16:42:48 +00:00
|
|
|
}
|
|
|
|
|
|
2023-09-18 08:35:02 +00:00
|
|
|
return completions.FirstOrDefault(x => x.Provider == provider);
|
2023-09-09 15:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|