Rename to TextGeneratives.

This commit is contained in:
Haiping Chen 2023-06-06 20:08:25 -05:00
parent 229fcfe6ea
commit aaa9261ac5
7 changed files with 21 additions and 19 deletions

View file

@ -1,8 +1,8 @@
using BotSharp.Abstraction.Models;
namespace BotSharp.Abstraction.TextCompletions;
namespace BotSharp.Abstraction.TextGeneratives;
public interface ITextCompletionProvider
public interface IChatCompletionProvider
{
string GetInstruction();
List<RoleDialogModel> GetChatSamples();

View file

@ -1,7 +1,7 @@
using BotSharp.Abstraction.Conversations;
using BotSharp.Abstraction.TextCompletions;
using BotSharp.Abstraction.TextGeneratives;
using BotSharp.Core.Conversations;
using BotSharp.Core.Plugins.TextCompletions.LLamaSharp;
using BotSharp.Core.Plugins.TextGeneratives.LLamaSharp;
using BotSharp.Core.Repository;
using BotSharp.Core.Services;
using EntityFrameworkCore.BootKit;
@ -64,6 +64,6 @@ public static class BotSharpServiceCollectionExtensions
config.Bind("LlamaSharp", settings);
return settings;
});
services.AddSingleton<ITextCompletionProvider, LlamaSharpCompletionProvider>();
services.AddSingleton<IChatCompletionProvider, ChatCompletionProvider>();
}
}

View file

@ -1,6 +1,6 @@
using BotSharp.Abstraction.Conversations;
using BotSharp.Abstraction.Models;
using BotSharp.Abstraction.TextCompletions;
using BotSharp.Abstraction.TextGeneratives;
using Microsoft.Extensions.DependencyInjection;
namespace BotSharp.Core.Services;
@ -21,7 +21,7 @@ public class PlatformMidware : IPlatformMidware
public async Task GetChatCompletionsAsync(List<RoleDialogModel> conversations,
Func<string, Task> onChunkReceived)
{
var handlers = _services.GetServices<ITextCompletionProvider>().ToList();
var handlers = _services.GetServices<IChatCompletionProvider>().ToList();
for (int i = 0; i < handlers.Count(); i++)
{
var handler = handlers[i];

View file

@ -1,17 +1,17 @@
using BotSharp.Abstraction.Models;
using BotSharp.Abstraction.Plugins;
using BotSharp.Abstraction.TextCompletions;
using BotSharp.Abstraction.TextGeneratives;
using LLama;
using System.IO;
namespace BotSharp.Core.Plugins.TextCompletions.LLamaSharp;
namespace BotSharp.Core.Plugins.TextGeneratives.LLamaSharp;
public class LlamaSharpCompletionProvider : ITextCompletionProvider, IBotSharpPlugin
public class ChatCompletionProvider : IChatCompletionProvider, IBotSharpPlugin
{
private readonly IChatModel _model;
private readonly LlamaSharpSettings _settings;
public LlamaSharpCompletionProvider(LlamaSharpSettings settings)
public ChatCompletionProvider(LlamaSharpSettings settings)
{
_settings = settings;
_model = new LLamaModel(new LLamaParams(model: _settings.ModelPath,

View file

@ -1,4 +1,4 @@
namespace BotSharp.Core.Plugins.TextCompletions.LLamaSharp;
namespace BotSharp.Core.Plugins.TextGeneratives.LLamaSharp;
public class LlamaSharpSettings
{

View file

@ -1,5 +1,6 @@
using BotSharp.Abstraction.TextCompletions;
using BotSharp.Abstraction.TextGeneratives;
using BotSharp.Platform.AzureAi;
using BotSharp.Plugin.AzureOpenAI.TextGeneratives;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -15,7 +16,7 @@ public static class AzureAiServiceCollectionExtensions
config.Bind("AzureAi", settings);
return settings;
});
services.AddScoped<ITextCompletionProvider, ChatCompletionHandler>();
services.AddScoped<IChatCompletionProvider, ChatCompletionProvider>();
return services;
}
}

View file

@ -1,19 +1,20 @@
using Azure;
using Azure.AI.OpenAI;
using BotSharp.Abstraction.Models;
using BotSharp.Abstraction.TextCompletions;
using BotSharp.Abstraction.TextGeneratives;
using BotSharp.Platform.AzureAi;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace BotSharp.Platform.AzureAi;
namespace BotSharp.Plugin.AzureOpenAI.TextGeneratives;
public class ChatCompletionHandler : ITextCompletionProvider
public class ChatCompletionProvider : IChatCompletionProvider
{
private readonly AzureAiSettings _settings;
public ChatCompletionHandler(AzureAiSettings settings)
public ChatCompletionProvider(AzureAiSettings settings)
{
_settings = settings;
}