diff --git a/BotSharp.sln b/BotSharp.sln index 258fd099..ec114349 100644 --- a/BotSharp.sln +++ b/BotSharp.sln @@ -43,7 +43,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Plugin.PaddleSharp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Plugin.MetaMessenger", "src\Plugins\BotSharp.Plugin.MetaMessenger\BotSharp.Plugin.MetaMessenger.csproj", "{8300F66D-9EB8-438A-BF0F-70DFBE07D9DE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.OpenAPI", "src\Infrastructure\BotSharp.OpenAPI\BotSharp.OpenAPI.csproj", "{7E63F5F8-4EA0-498B-ABFE-2BBE4D7DDBA7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.OpenAPI", "src\Infrastructure\BotSharp.OpenAPI\BotSharp.OpenAPI.csproj", "{7E63F5F8-4EA0-498B-ABFE-2BBE4D7DDBA7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.LLamaSharp", "src\Plugins\BotSharp.Plugin.LLamaSharp\BotSharp.Plugin.LLamaSharp.csproj", "{46B7B54F-1425-4C9D-824A-9B826855D249}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -157,6 +159,14 @@ Global {7E63F5F8-4EA0-498B-ABFE-2BBE4D7DDBA7}.Release|Any CPU.Build.0 = Release|Any CPU {7E63F5F8-4EA0-498B-ABFE-2BBE4D7DDBA7}.Release|x64.ActiveCfg = Release|Any CPU {7E63F5F8-4EA0-498B-ABFE-2BBE4D7DDBA7}.Release|x64.Build.0 = Release|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Debug|x64.ActiveCfg = Debug|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Debug|x64.Build.0 = Debug|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Release|Any CPU.Build.0 = Release|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Release|x64.ActiveCfg = Release|Any CPU + {46B7B54F-1425-4C9D-824A-9B826855D249}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -179,6 +189,7 @@ Global {0308FBFD-57EB-4709-9AE4-A80D516AD84D} = {B797EC3E-B5B9-4047-A6C8-6D330B7C6763} {8300F66D-9EB8-438A-BF0F-70DFBE07D9DE} = {64264688-0F5C-4AB0-8F2B-B59B717CCE00} {7E63F5F8-4EA0-498B-ABFE-2BBE4D7DDBA7} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749} + {46B7B54F-1425-4C9D-824A-9B826855D249} = {D5293208-2BEF-42FC-A64C-5954F61720BA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A9969D89-C98B-40A5-A12B-FC87E55B3A19} diff --git a/docs/architecture/assets/diagram.drawio b/docs/architecture/assets/diagram.drawio new file mode 100644 index 00000000..95fe5504 --- /dev/null +++ b/docs/architecture/assets/diagram.drawio @@ -0,0 +1 @@ +zZVdb4MgFIZ/jZdNFLraXbau3W72kXTLromcCimCo3Ta/frBxFq1TdZkSZcYA+85HOB5EQOc5NW9JgV7VBREgEJaBfguQCgaIxS4J6T7WomnYS1kmlOf1Aor/gVebNJ2nMK2k2iUEoYXXTFVUkJqOhrRWpXdtLUS3VkLksFAWKVEDNV3Tg2r1SmKW/0BeMaamaPJbR3JSZPsd7JlhKrySMKLACdaKVO38ioB4eA1XOpxyzPRw8I0SPObAZundLwc4dnHm6axmC03rxUa+SqfROz8hhNGjF+w2TcUtNpJCq5QFOB5ybiBVUFSFy2t71ZjJhc+7EuCNlCdXWt0IGCPDqgcjN7bFD8AjT20fa9fth5EDVh2xH/iNeJtzw6lWzK24eFcAAoNQL0wJeHqpMb/jhQekHp2nMK5JlxenRfu8cLxtXnFpz5BRypUa/uaZXZn2wE3S8B04WyNVhtIlFDaKtIdTjxfcyF6EhE8k7ab2rpg9bnjye2NN/OBnFPqpjnpRutX+DeGRLhnyPRmYMjkhB/4cj9st71uf2JHPy28+AY= \ No newline at end of file diff --git a/docs/architecture/hooks.md b/docs/architecture/hooks.md index df33ddee..495415c3 100644 --- a/docs/architecture/hooks.md +++ b/docs/architecture/hooks.md @@ -1 +1,31 @@ -# Hooks \ No newline at end of file +# Hooks + +`Hook` is a place in `BotSharp` that allows you to tap in to a module to either provide different behavior or to react. + +## Agent Hook +`IAgentHook` +```csharp +bool OnAgentLoading(ref string id); +bool OnInstructionLoaded(ref string instruction); +bool OnFunctionsLoaded(ref string functions); +bool OnSamplesLoaded(ref string samples); +Agent OnAgentLoaded(); +``` + +## Conversation Hook +`IConversationHook` +```csharp +Task OnDialogsLoaded(List dialogs); +Task BeforeCompletion(); +Task OnFunctionExecuting(RoleDialogModel message); +Task OnFunctionExecuted(RoleDialogModel message); +Task AfterCompletion(RoleDialogModel message); +``` + + +### Conversation State Hook +`IConversationHook` +```csharp +Task OnStateLoaded(ConversationState state); +Task OnStateChanged(string name, string preValue, string currentValue); +``` \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index c3730fe6..4dc4cdbd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -73,14 +73,16 @@ The main documentation for the site is organized into the following sections: knowledge-base/similarity-search knowledge-base/build-qa-bot -.. _prompting: +.. _llm: .. toctree:: :maxdepth: 3 :caption: Prompt Engineering - prompt/intro + prompt/prompt prompt/template + llm/function + llm/few-shot-learning .. _architecture-docs: diff --git a/docs/llm/few-shot-learning.md b/docs/llm/few-shot-learning.md new file mode 100644 index 00000000..d0936085 --- /dev/null +++ b/docs/llm/few-shot-learning.md @@ -0,0 +1 @@ +# Few-Shot Learning \ No newline at end of file diff --git a/docs/llm/function.md b/docs/llm/function.md new file mode 100644 index 00000000..f2a62bf9 --- /dev/null +++ b/docs/llm/function.md @@ -0,0 +1 @@ +# Function \ No newline at end of file diff --git a/docs/prompt/intro.md b/docs/llm/prompt.md similarity index 100% rename from docs/prompt/intro.md rename to docs/llm/prompt.md diff --git a/docs/prompt/template.md b/docs/llm/template.md similarity index 100% rename from docs/prompt/template.md rename to docs/llm/template.md diff --git a/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj b/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj index a73c2169..48aa9074 100644 --- a/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj +++ b/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable 10.0 - 0.8.0 + 0.9.0 Icon.png diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj index 6b4b0970..ceb5a348 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj +++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj @@ -4,7 +4,7 @@ netstandard2.1 10.0 false - 0.8.0 + 0.9.0 @@ -76,7 +76,6 @@ - diff --git a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj index ef6a4193..d1a16a68 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj +++ b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj @@ -4,7 +4,7 @@ net6.0 enable enable - 0.8.0 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.AzureOpenAI/BotSharp.Plugin.AzureOpenAI.csproj b/src/Plugins/BotSharp.Plugin.AzureOpenAI/BotSharp.Plugin.AzureOpenAI.csproj index 0b609d28..dfc28a95 100644 --- a/src/Plugins/BotSharp.Plugin.AzureOpenAI/BotSharp.Plugin.AzureOpenAI.csproj +++ b/src/Plugins/BotSharp.Plugin.AzureOpenAI/BotSharp.Plugin.AzureOpenAI.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable 10 - 0.8.0 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj b/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj index 2ac302ae..e9e233a9 100644 --- a/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj +++ b/src/Plugins/BotSharp.Plugin.ChatbotUI/BotSharp.Plugin.ChatbotUI.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable 10 - 0.8.0 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.HuggingFace/BotSharp.Plugin.HuggingFace.csproj b/src/Plugins/BotSharp.Plugin.HuggingFace/BotSharp.Plugin.HuggingFace.csproj index f6f00297..1f7fd6a1 100644 --- a/src/Plugins/BotSharp.Plugin.HuggingFace/BotSharp.Plugin.HuggingFace.csproj +++ b/src/Plugins/BotSharp.Plugin.HuggingFace/BotSharp.Plugin.HuggingFace.csproj @@ -4,6 +4,7 @@ netstandard2.1 enable 10 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj b/src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj new file mode 100644 index 00000000..c4f3e435 --- /dev/null +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj @@ -0,0 +1,18 @@ + + + + netstandard2.1 + enable + 10 + 0.9.0 + + + + + + + + + + + diff --git a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LLamaSharpPlugin.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/LLamaSharpPlugin.cs similarity index 80% rename from src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LLamaSharpPlugin.cs rename to src/Plugins/BotSharp.Plugin.LLamaSharp/LLamaSharpPlugin.cs index 66bd11f8..370b574d 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LLamaSharpPlugin.cs +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/LLamaSharpPlugin.cs @@ -1,5 +1,9 @@ using BotSharp.Abstraction.MLTasks; +using BotSharp.Abstraction.Plugins; +using BotSharp.Plugin.LLamaSharp.Providers; +using BotSharp.Plugin.LLamaSharp.Settings; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; namespace BotSharp.Core.Plugins.LLamaSharp; diff --git a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LlamaAiModel.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/LlamaAiModel.cs similarity index 93% rename from src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LlamaAiModel.cs rename to src/Plugins/BotSharp.Plugin.LLamaSharp/LlamaAiModel.cs index a4f4336e..709f2ba1 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LlamaAiModel.cs +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/LlamaAiModel.cs @@ -1,3 +1,4 @@ +using BotSharp.Plugin.LLamaSharp.Settings; using LLama; using LLama.Common; diff --git a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/ChatCompletionProvider.cs similarity index 89% rename from src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/ChatCompletionProvider.cs rename to src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/ChatCompletionProvider.cs index 75e845ac..8d4938d6 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/ChatCompletionProvider.cs @@ -1,10 +1,16 @@ using BotSharp.Abstraction.Agents.Models; using BotSharp.Abstraction.Conversations.Models; using BotSharp.Abstraction.MLTasks; +using BotSharp.Core.Plugins.LLamaSharp; using LLama; using LLama.Common; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; -namespace BotSharp.Core.Plugins.LLamaSharp; +namespace BotSharp.Plugin.LLamaSharp.Providers; public class ChatCompletionProvider : IChatCompletion { @@ -19,8 +25,8 @@ public class ChatCompletionProvider : IChatCompletion throw new NotImplementedException(); } - public async Task GetChatCompletionsAsync(Agent agent, - List conversations, + public async Task GetChatCompletionsAsync(Agent agent, + List conversations, Func onMessageReceived, Func onFunctionExecuting) { diff --git a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/TextCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextCompletionProvider.cs similarity index 82% rename from src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/TextCompletionProvider.cs rename to src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextCompletionProvider.cs index b7ac3cb7..2548593c 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/TextCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextCompletionProvider.cs @@ -1,8 +1,12 @@ using BotSharp.Abstraction.MLTasks; +using BotSharp.Core.Plugins.LLamaSharp; using LLama; using LLama.Common; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Threading.Tasks; -namespace BotSharp.Core.Plugins.LLamaSharp; +namespace BotSharp.Plugin.LLamaSharp.Providers; public class TextCompletionProvider : ITextCompletion { diff --git a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/TextEmbeddingProvider.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextEmbeddingProvider.cs similarity index 85% rename from src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/TextEmbeddingProvider.cs rename to src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextEmbeddingProvider.cs index 5608971a..0738c1a4 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/TextEmbeddingProvider.cs +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextEmbeddingProvider.cs @@ -1,8 +1,11 @@ using BotSharp.Abstraction.MLTasks; +using BotSharp.Plugin.LLamaSharp.Settings; using LLama; using LLama.Common; +using System; +using System.Collections.Generic; -namespace BotSharp.Core.Plugins.LLamaSharp; +namespace BotSharp.Plugin.LLamaSharp.Providers; public class TextEmbeddingProvider : ITextEmbedding { diff --git a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LlamaSharpSettings.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/Settings/LlamaSharpSettings.cs similarity index 87% rename from src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LlamaSharpSettings.cs rename to src/Plugins/BotSharp.Plugin.LLamaSharp/Settings/LlamaSharpSettings.cs index 01507188..fc5d7d44 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/LLamaSharp/LlamaSharpSettings.cs +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/Settings/LlamaSharpSettings.cs @@ -1,4 +1,4 @@ -namespace BotSharp.Core.Plugins.LLamaSharp; +namespace BotSharp.Plugin.LLamaSharp.Settings; public class LlamaSharpSettings { diff --git a/src/Plugins/BotSharp.Plugin.MetaAI/BotSharp.Plugin.MetaAI.csproj b/src/Plugins/BotSharp.Plugin.MetaAI/BotSharp.Plugin.MetaAI.csproj index cb65f0f7..915bebbb 100644 --- a/src/Plugins/BotSharp.Plugin.MetaAI/BotSharp.Plugin.MetaAI.csproj +++ b/src/Plugins/BotSharp.Plugin.MetaAI/BotSharp.Plugin.MetaAI.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable 10 - 0.5.1 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.MetaMessenger/BotSharp.Plugin.MetaMessenger.csproj b/src/Plugins/BotSharp.Plugin.MetaMessenger/BotSharp.Plugin.MetaMessenger.csproj index 15f0ca00..fe2e95fd 100644 --- a/src/Plugins/BotSharp.Plugin.MetaMessenger/BotSharp.Plugin.MetaMessenger.csproj +++ b/src/Plugins/BotSharp.Plugin.MetaMessenger/BotSharp.Plugin.MetaMessenger.csproj @@ -3,6 +3,7 @@ netstandard2.1 10 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj b/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj index a0ce0561..0069f97f 100644 --- a/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj +++ b/src/Plugins/BotSharp.Plugin.PaddleSharp/BotSharp.Plugin.PaddleSharp.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable 10 - 0.5.1 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.Qdrant/BotSharp.Plugin.Qdrant.csproj b/src/Plugins/BotSharp.Plugin.Qdrant/BotSharp.Plugin.Qdrant.csproj index 1b4afb70..9a7edfcc 100644 --- a/src/Plugins/BotSharp.Plugin.Qdrant/BotSharp.Plugin.Qdrant.csproj +++ b/src/Plugins/BotSharp.Plugin.Qdrant/BotSharp.Plugin.Qdrant.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable 10 - 0.6.0 + 0.9.0 diff --git a/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj b/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj index 318c1570..06c78a77 100644 --- a/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj +++ b/src/Plugins/BotSharp.Plugin.WeChat/BotSharp.Plugin.WeChat.csproj @@ -12,7 +12,7 @@ https://github.com/Oceania2018/botsharp-channel-weixin Apache 2.0 botsharp, wechat, wexin, chatbot - 0.6.0 + 0.9.0 diff --git a/src/WebStarter/WebStarter.csproj b/src/WebStarter/WebStarter.csproj index d03a2f39..e8ef139f 100644 --- a/src/WebStarter/WebStarter.csproj +++ b/src/WebStarter/WebStarter.csproj @@ -39,6 +39,7 @@ +