From 4012305e589003f310baa448782bbf13644ba1bf Mon Sep 17 00:00:00 2001
From: Haiping Chen <101423@smsassist.com>
Date: Mon, 2 Dec 2024 15:18:16 -0600
Subject: [PATCH] Init Core.Rule module
---
.../Agents/Enums/BuiltInAgentId.cs | 5 ++++
.../BotSharp.Core.Rules.csproj | 13 ++++++++++
.../BotSharp.Core.Rules/RulesPlugin.cs | 19 +++++++++++++++
.../BotSharp.Core.Rules/Using.cs | 4 ++++
.../BotSharpSideCarPlugin.cs | 6 +++--
.../BotSharp.Plugin.AnthropicAI.csproj | 2 +-
...tSharp.Plugin.JavaScriptInterpreter.csproj | 17 +++++++++++++
.../JsInterpreterPlugin.cs | 24 +++++++++++++++++++
.../BotSharp.Plugin.LLamaSharp.csproj | 2 +-
.../LlamaAiModel.cs | 1 -
.../Providers/TextEmbeddingProvider.cs | 8 ++++---
.../BotSharp.Plugin.PythonInterpreter.csproj | 2 +-
12 files changed, 94 insertions(+), 9 deletions(-)
create mode 100644 src/Infrastructure/BotSharp.Core.Rules/BotSharp.Core.Rules.csproj
create mode 100644 src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs
create mode 100644 src/Infrastructure/BotSharp.Core.Rules/Using.cs
create mode 100644 src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/BotSharp.Plugin.JavaScriptInterpreter.csproj
create mode 100644 src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/JsInterpreterPlugin.cs
diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/BuiltInAgentId.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/BuiltInAgentId.cs
index c3c69f08..f2f64b6b 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/BuiltInAgentId.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/BuiltInAgentId.cs
@@ -51,4 +51,9 @@ public class BuiltInAgentId
/// Evaluate prompt and conversation
///
public const string Evaluator = "dfd9b46d-d00c-40af-8a75-3fbdc2b89869";
+
+ ///
+ /// Translates user-defined natural language rules into programmatic code
+ ///
+ public const string RuleEncoder = "6acfb93c-3412-402e-9ba5-c5d3cd8f0161";
}
diff --git a/src/Infrastructure/BotSharp.Core.Rules/BotSharp.Core.Rules.csproj b/src/Infrastructure/BotSharp.Core.Rules/BotSharp.Core.Rules.csproj
new file mode 100644
index 00000000..caef78b8
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Core.Rules/BotSharp.Core.Rules.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs b/src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs
new file mode 100644
index 00000000..14177437
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs
@@ -0,0 +1,19 @@
+namespace BotSharp.Core.Rules;
+
+public class RulesPlugin : IBotSharpPlugin
+{
+ public string Id => "0197c1bc-9ae6-4c56-a305-8a1b4095bebc";
+ public string Name => "BotSharp Rules";
+ public string Description => "Translates user-defined natural language rules into programmatic code and is responsible for executing these rules under user-specified conditions.";
+ public string IconUrl => "https://w7.pngwing.com/pngs/442/614/png-transparent-regulation-computer-icons-regulatory-compliance-medical-device-manufacturing-others-miscellaneous-blue-text-thumbnail.png";
+
+ public string[] AgentIds =
+ [
+ BuiltInAgentId.RuleEncoder
+ ];
+
+ public void RegisterDI(IServiceCollection services, IConfiguration config)
+ {
+
+ }
+}
diff --git a/src/Infrastructure/BotSharp.Core.Rules/Using.cs b/src/Infrastructure/BotSharp.Core.Rules/Using.cs
new file mode 100644
index 00000000..d982daae
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Core.Rules/Using.cs
@@ -0,0 +1,4 @@
+global using BotSharp.Abstraction.Agents.Enums;
+global using BotSharp.Abstraction.Plugins;
+global using Microsoft.Extensions.Configuration;
+global using Microsoft.Extensions.DependencyInjection;
\ No newline at end of file
diff --git a/src/Infrastructure/BotSharp.Core.SideCar/BotSharpSideCarPlugin.cs b/src/Infrastructure/BotSharp.Core.SideCar/BotSharpSideCarPlugin.cs
index efef5201..d3ace389 100644
--- a/src/Infrastructure/BotSharp.Core.SideCar/BotSharpSideCarPlugin.cs
+++ b/src/Infrastructure/BotSharp.Core.SideCar/BotSharpSideCarPlugin.cs
@@ -8,8 +8,10 @@ namespace BotSharp.Core.SideCar;
public class BotSharpSideCarPlugin : IBotSharpPlugin
{
public string Id => "06e5a276-bba0-45af-9625-889267c341c9";
- public string Name => "Side Car";
- public string Description => "Provides side car for calling agent cluster in conversation";
+ public string Name => "BotSharp SideCar";
+ public string Description => "Provide side car pattern to to better handle Agent Cluster calls in the same conversation. Agent cluster is composed of multiple Routing Agents.";
+ public string? IconUrl => "https://icons.veryicon.com/png/128/internet--web/2022-alibaba-cloud-product-icon-cloud/aliyuncvc-cloud-video-conference.png";
+
public SettingsMeta Settings => new SettingsMeta("SideCar");
public object GetNewSettingsInstance() => new SideCarSettings();
diff --git a/src/Plugins/BotSharp.Plugin.AnthropicAI/BotSharp.Plugin.AnthropicAI.csproj b/src/Plugins/BotSharp.Plugin.AnthropicAI/BotSharp.Plugin.AnthropicAI.csproj
index c5bd88d0..d053f4d6 100644
--- a/src/Plugins/BotSharp.Plugin.AnthropicAI/BotSharp.Plugin.AnthropicAI.csproj
+++ b/src/Plugins/BotSharp.Plugin.AnthropicAI/BotSharp.Plugin.AnthropicAI.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/BotSharp.Plugin.JavaScriptInterpreter.csproj b/src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/BotSharp.Plugin.JavaScriptInterpreter.csproj
new file mode 100644
index 00000000..4596ce1b
--- /dev/null
+++ b/src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/BotSharp.Plugin.JavaScriptInterpreter.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/JsInterpreterPlugin.cs b/src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/JsInterpreterPlugin.cs
new file mode 100644
index 00000000..e3811809
--- /dev/null
+++ b/src/Plugins/BotSharp.Plugin.JavaScriptInterpreter/JsInterpreterPlugin.cs
@@ -0,0 +1,24 @@
+using BotSharp.Abstraction.Plugins;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace BotSharp.Plugin.JavaScriptInterpreter;
+
+public class JsInterpreterPlugin : IBotSharpAppPlugin
+{
+ public string Id => "7a5a8cd7-26d9-4ac3-9d79-d02084bea372";
+ public string Name => "JavaScript Interpreter";
+ public string Description => "";
+ public string? IconUrl => "";
+
+ public void Configure(IApplicationBuilder app)
+ {
+
+ }
+
+ public void RegisterDI(IServiceCollection services, IConfiguration config)
+ {
+
+ }
+}
diff --git a/src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj b/src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj
index bd7cf7b7..68ce651c 100644
--- a/src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj
+++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/BotSharp.Plugin.LLamaSharp.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/src/Plugins/BotSharp.Plugin.LLamaSharp/LlamaAiModel.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/LlamaAiModel.cs
index 9d55dead..a7d83def 100644
--- a/src/Plugins/BotSharp.Plugin.LLamaSharp/LlamaAiModel.cs
+++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/LlamaAiModel.cs
@@ -36,7 +36,6 @@ public class LlamaAiModel
_params = new ModelParams(Path.Combine(_settings.ModelDir, model))
{
ContextSize = (uint)_settings.MaxContextLength,
- Seed = 1337,
GpuLayerCount = _settings.NumberOfGpuLayer
};
diff --git a/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextEmbeddingProvider.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextEmbeddingProvider.cs
index a9288064..1ec461ae 100644
--- a/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextEmbeddingProvider.cs
+++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/TextEmbeddingProvider.cs
@@ -1,4 +1,6 @@
using System.IO;
+using System.Xml.Linq;
+using static System.Net.Mime.MediaTypeNames;
namespace BotSharp.Plugin.LLamaSharp.Providers;
@@ -19,7 +21,7 @@ public class TextEmbeddingProvider : ITextEmbedding
_settings = settings;
}
- public Task GetVectorAsync(string text)
+ public async Task GetVectorAsync(string text)
{
if (_embedder == null)
{
@@ -29,10 +31,10 @@ public class TextEmbeddingProvider : ITextEmbedding
_embedder = new LLamaEmbedder(weights, @params);
}
- return _embedder.GetEmbeddings(text);
+ return (await _embedder.GetEmbeddings(text)).First();
}
- public Task> GetVectorsAsync(List texts)
+ public async Task> GetVectorsAsync(List texts)
{
throw new NotImplementedException();
}
diff --git a/src/Plugins/BotSharp.Plugin.PythonInterpreter/BotSharp.Plugin.PythonInterpreter.csproj b/src/Plugins/BotSharp.Plugin.PythonInterpreter/BotSharp.Plugin.PythonInterpreter.csproj
index b3293a0f..c5e3d4ff 100644
--- a/src/Plugins/BotSharp.Plugin.PythonInterpreter/BotSharp.Plugin.PythonInterpreter.csproj
+++ b/src/Plugins/BotSharp.Plugin.PythonInterpreter/BotSharp.Plugin.PythonInterpreter.csproj
@@ -25,7 +25,7 @@
-
+