Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public interface IAgentService
Task<List<AgentCodeScript>> GetAgentCodeScripts(string agentId, AgentCodeScriptFilter? filter = null)
=> Task.FromResult(new List<AgentCodeScript>());

Task<string?> GetAgentCodeScript(string agentId, string scriptName, string scriptType = AgentCodeScriptType.Src)
=> Task.FromResult(string.Empty);
Task<AgentCodeScript?> GetAgentCodeScript(string agentId, string scriptName, string scriptType = AgentCodeScriptType.Src)
=> Task.FromResult((AgentCodeScript?)null);

Task<bool> UpdateAgentCodeScripts(string agentId, List<AgentCodeScript> codeScripts, AgentCodeScriptUpdateOptions? options = null)
=> Task.FromResult(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ public class AgentCodeScript : AgentCodeScriptBase
public string Id { get; set; }
public string AgentId { get; set; } = null!;

public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;

public AgentCodeScript() : base()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class AgentSettings
/// <summary>
/// This is the default LLM config for agent
/// </summary>
public AgentLlmConfig LlmConfig { get; set; }
= new AgentLlmConfig();
public AgentLlmConfig LlmConfig { get; set; } = new AgentLlmConfig();

/// <summary>
/// General coding settings
/// </summary>
public CodingSettings Coding { get; set; } = new CodingSettings();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BotSharp.Abstraction.Coding.Enums;

public static class BuiltInCodeProcessor
{
public const string PyInterpreter = "botsharp-py-interpreter";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ public class CodeGenerationOptions : LlmConfigBase
public string? TemplateName { get; set; }

/// <summary>
/// The programming language
/// Programming language
/// </summary>
[JsonPropertyName("language")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Language { get; set; } = "python";
[JsonPropertyName("programming_language")]
public string? ProgrammingLanguage { get; set; }

/// <summary>
/// Data that can be used to fill in the prompt
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace BotSharp.Abstraction.Coding.Settings;

public class CodingSettings
{
/// <summary>
/// Llm provider to generate code script
/// </summary>
public string? Provider { get; set; }

/// <summary>
/// Llm model to generate code script
/// </summary>
public string? Model { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using BotSharp.Abstraction.Files.Options;
using BotSharp.Abstraction.Files.Responses;
using BotSharp.Abstraction.Knowledges.Options;
using BotSharp.Abstraction.Knowledges.Responses;

namespace BotSharp.Abstraction.Files.Proccessors;

Expand All @@ -9,4 +11,7 @@ public interface IFileProcessor

Task<FileHandleResponse> HandleFilesAsync(Agent agent, string text, IEnumerable<InstructFileModel> files, FileHandleOptions? options = null)
=> throw new NotImplementedException();

Task<FileKnowledgeResponse> GetFileKnowledgeAsync(FileBinaryDataModel file, FileKnowledgeProcessOptions? options = null)
=> throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace BotSharp.Abstraction.Instructs.Contexts;

public class CodeInstructContext
{
public string CodeScript { get; set; }
public string ScriptName { get; set; }
public string ScriptContent { get; set; }
public string ScriptType { get; set; }
public List<KeyValue> Arguments { get; set; } = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ public class InstructOptions
/// <summary>
/// Image convert provider
/// </summary>
public string? ImageConvertProvider { get; set; }
public string? ImageConverter { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public interface IKnowledgeService
/// </summary>
/// <param name="collectionName"></param>
/// <param name="files"></param>
/// <param name="option"></param>
/// <returns></returns>
Task<UploadKnowledgeResponse> UploadDocumentsToKnowledge(string collectionName, IEnumerable<ExternalFileModel> files, ChunkOption? option = null);
Task<UploadKnowledgeResponse> UploadDocumentsToKnowledge(string collectionName, IEnumerable<ExternalFileModel> files, KnowledgeDocOptions? options = null);
/// <summary>
/// Save document content to knowledgebase without saving the document
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using BotSharp.Abstraction.VectorStorage.Models;

namespace BotSharp.Abstraction.Knowledges.Models;

public class FileKnowledgeModel
{
public IEnumerable<string> Contents { get; set; } = [];
public IDictionary<string, VectorPayloadValue>? Payload { get; set; }
}


public class FileKnowledgeWrapper
{
public Guid FileId { get; set; }
public string? FileSource { get; set; }
public FileBinaryDataModel FileData { get; set; }
public IEnumerable<FileKnowledgeModel> FileKnowledges { get; set; } = [];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BotSharp.Abstraction.Files.Models;
namespace BotSharp.Abstraction.Knowledges.Models;

public class KnowledgeFileModel
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace BotSharp.Abstraction.Knowledges.Options;

public class FileKnowledgeProcessOptions
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BotSharp.Abstraction.Knowledges.Options;

public class KnowledgeDocOptions
{
public string? Processor { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BotSharp.Abstraction.Knowledges.Responses;

public class FileKnowledgeResponse
{
public IEnumerable<FileKnowledgeModel> Knowledges { get; set; } = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
List<User> GetUsersByAffiliateId(string affiliateId) => throw new NotImplementedException();
User? GetUserByUserName(string userName) => throw new NotImplementedException();
void UpdateUserName(string userId, string userName) => throw new NotImplementedException();
Dashboard? GetDashboard(string id = null) => throw new NotImplementedException();

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Cannot convert null literal to non-nullable reference type.
void CreateUser(User user) => throw new NotImplementedException();
void UpdateExistUser(string userId, User user) => throw new NotImplementedException();
void UpdateUserVerified(string userId) => throw new NotImplementedException();
Expand Down Expand Up @@ -114,7 +114,7 @@
#region Agent Code
List<AgentCodeScript> GetAgentCodeScripts(string agentId, AgentCodeScriptFilter? filter = null)
=> throw new NotImplementedException();
string? GetAgentCodeScript(string agentId, string scriptName, string scriptType = AgentCodeScriptType.Src)
AgentCodeScript? GetAgentCodeScript(string agentId, string scriptName, string scriptType = AgentCodeScriptType.Src)
=> throw new NotImplementedException();
bool UpdateAgentCodeScripts(string agentId, List<AgentCodeScript> scripts, AgentCodeScriptDbUpdateOptions? options = null)
=> throw new NotImplementedException();
Expand Down
12 changes: 11 additions & 1 deletion src/Infrastructure/BotSharp.Abstraction/Rules/IRuleEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@ namespace BotSharp.Abstraction.Rules;

public interface IRuleEngine
{
Task<IEnumerable<string>> Triggered(IRuleTrigger trigger, string data, List<MessageState>? states = null);
/// <summary>
/// Trigger the rule that is subscribed by agents.
/// </summary>
/// <param name="trigger"></param>
/// <param name="text"></param>
/// <param name="states"></param>
/// <param name="options"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
Task<IEnumerable<string>> Triggered(IRuleTrigger trigger, string text, IEnumerable<MessageState>? states = null, RuleTriggerOptions? options = null)
=> throw new NotImplementedException();
}
12 changes: 12 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Text.Json;

namespace BotSharp.Abstraction.Rules;

public interface IRuleTrigger
Expand All @@ -9,4 +11,14 @@ public interface IRuleTrigger
string EntityType { get; set; }

string EntityId { get; set; }

/// <summary>
/// The default arguments as input to code trigger (display purpose)
/// </summary>
JsonDocument OutputArgs => JsonDocument.Parse("{}");

/// <summary>
/// Explain the purpose of rule trigger (display purpose)
/// </summary>
string Statement => string.Empty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Text.Json;

namespace BotSharp.Abstraction.Rules.Options;

public class RuleTriggerOptions
{
/// <summary>
/// Code processor provider
/// </summary>
public string? CodeProcessor { get; set; }

/// <summary>
/// Code script name
/// </summary>
public string? CodeScriptName { get; set; }

/// <summary>
/// Argument name as an input key to the code script
/// </summary>
public string? ArgumentName { get; set; }

/// <summary>
/// Json arguments as an input value to the code script
/// </summary>
public JsonDocument? ArgumentContent { get; set; }
}
4 changes: 3 additions & 1 deletion src/Infrastructure/BotSharp.Abstraction/Using.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
global using BotSharp.Abstraction.Knowledges.Models;
global using BotSharp.Abstraction.Crontab.Models;
global using BotSharp.Abstraction.MCP.Models;
global using BotSharp.Abstraction.Settings;
global using BotSharp.Abstraction.Settings;
global using BotSharp.Abstraction.Rules.Options;
global using BotSharp.Abstraction.Coding.Settings;
Loading
Loading