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; using BotSharp.Abstraction.Models;
namespace BotSharp.Abstraction.TextCompletions; namespace BotSharp.Abstraction.TextGeneratives;
public interface ITextCompletionProvider public interface IChatCompletionProvider
{ {
string GetInstruction(); string GetInstruction();
List<RoleDialogModel> GetChatSamples(); List<RoleDialogModel> GetChatSamples();

View file

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

View file

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

View file

@ -1,17 +1,17 @@
using BotSharp.Abstraction.Models; using BotSharp.Abstraction.Models;
using BotSharp.Abstraction.Plugins; using BotSharp.Abstraction.Plugins;
using BotSharp.Abstraction.TextCompletions; using BotSharp.Abstraction.TextGeneratives;
using LLama; using LLama;
using System.IO; 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 IChatModel _model;
private readonly LlamaSharpSettings _settings; private readonly LlamaSharpSettings _settings;
public LlamaSharpCompletionProvider(LlamaSharpSettings settings) public ChatCompletionProvider(LlamaSharpSettings settings)
{ {
_settings = settings; _settings = settings;
_model = new LLamaModel(new LLamaParams(model: _settings.ModelPath, _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 public class LlamaSharpSettings
{ {

View file

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

View file

@ -1,19 +1,20 @@
using Azure; using Azure;
using Azure.AI.OpenAI; using Azure.AI.OpenAI;
using BotSharp.Abstraction.Models; using BotSharp.Abstraction.Models;
using BotSharp.Abstraction.TextCompletions; using BotSharp.Abstraction.TextGeneratives;
using BotSharp.Platform.AzureAi;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; 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; private readonly AzureAiSettings _settings;
public ChatCompletionHandler(AzureAiSettings settings) public ChatCompletionProvider(AzureAiSettings settings)
{ {
_settings = settings; _settings = settings;
} }