Skip to content
10 changes: 9 additions & 1 deletion src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using BotSharp.Abstraction.Agents.Options;
using BotSharp.Abstraction.Coding.Models;
using BotSharp.Abstraction.Coding.Options;
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Plugins.Models;
using BotSharp.Abstraction.Repositories.Filters;
Expand Down Expand Up @@ -51,7 +53,7 @@ public interface IAgentService
/// <returns>Original agent information</returns>
Task<Agent> GetAgent(string id);

Task<bool> DeleteAgent(string id);
Task<bool> DeleteAgent(string id, AgentDeleteOptions? options = null);
Task UpdateAgent(Agent agent, AgentField updateField);

/// <summary>
Expand All @@ -75,4 +77,10 @@ Task<List<AgentCodeScript>> GetAgentCodeScripts(string agentId, AgentCodeScriptF

Task<bool> UpdateAgentCodeScripts(string agentId, List<AgentCodeScript> codeScripts, AgentCodeScriptUpdateOptions? options = null)
=> Task.FromResult(false);

Task<bool> DeleteAgentCodeScripts(string agentId, List<AgentCodeScript>? codeScripts = null)
=> Task.FromResult(false);

Task<CodeGenerationResult> GenerateCodeScript(string agentId, string text, CodeProcessOptions? options = null)
=> Task.FromResult(new CodeGenerationResult());
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ namespace BotSharp.Abstraction.Agents.Models;
public class AgentRule
{
[JsonPropertyName("trigger_name")]
public string TriggerName { get; set; }
public string TriggerName { get; set; } = string.Empty;

[JsonPropertyName("disabled")]
public bool Disabled { get; set; }

[JsonPropertyName("criteria")]
public string Criteria { get; set; }
public string Criteria { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ namespace BotSharp.Abstraction.Agents.Options;

public class AgentCodeScriptUpdateOptions : AgentCodeScriptDbUpdateOptions
{
[JsonPropertyName("delete_if_not_included")]
public bool DeleteIfNotIncluded { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace BotSharp.Abstraction.Agents.Options;

public class AgentDeleteOptions
{
[JsonPropertyName("delete_role_agents")]
public bool DeleteRoleAgents { get; set; }

[JsonPropertyName("delete_user_agents")]
public bool DeleteUserAgents { get; set; }

[JsonPropertyName("to_delete_code_scripts")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<AgentCodeScript>? ToDeleteCodeScripts { get; set; }
}

This file was deleted.

12 changes: 12 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Chart/IChartProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using BotSharp.Abstraction.Chart.Models;
using BotSharp.Abstraction.Chart.Options;

namespace BotSharp.Abstraction.Chart;

public interface IChartProcessor
{
public string Provider { get; }

Task<ChartDataResult?> GetConversationChartDataAsync(string conversationId, string messageId, ChartDataOptions? options = null)
=> throw new NotImplementedException();
}

This file was deleted.

18 changes: 18 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Coding/ICodeProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using BotSharp.Abstraction.Coding.Models;
using BotSharp.Abstraction.Coding.Options;
using BotSharp.Abstraction.Coding.Responses;

Expand All @@ -7,6 +8,23 @@ public interface ICodeProcessor
{
string Provider { get; }

/// <summary>
/// Run code script
/// </summary>
/// <param name="codeScript">The code scirpt to run</param>
/// <param name="options">Code script execution options</param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
Task<CodeInterpretResponse> RunAsync(string codeScript, CodeInterpretOptions? options = null)
=> throw new NotImplementedException();

/// <summary>
/// Generate code script
/// </summary>
/// <param name="text">User requirement to generate code script</param>
/// <param name="options">Code script generation options</param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
Task<CodeGenerationResult> GenerateCodeScriptAsync(string text, CodeGenerationOptions? options = null)
=> throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace BotSharp.Abstraction.Coding.Models;

public class CodeGenerationResult : ResponseBase
{
public string Content { get; set; }
public string Language { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace BotSharp.Abstraction.Coding.Options;

public class CodeGenerationOptions : LlmConfigBase
{
/// <summary>
/// Agent id to get instruction
/// </summary>
[JsonPropertyName("agent_id")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? AgentId { get; set; }

/// <summary>
/// Template (prompt) name
/// </summary>
[JsonPropertyName("template_name")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TemplateName { get; set; }

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

/// <summary>
/// Data that can be used to fill in the prompt
/// </summary>
[JsonPropertyName("data")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, object>? Data { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace BotSharp.Abstraction.Coding.Options;

public class CodeProcessOptions : CodeGenerationOptions
{
/// <summary>
/// Code processor provider
/// </summary>
[JsonPropertyName("processor")]
public string? Processor { get; set; }

/// <summary>
/// Whether to save the generated code script to db
/// </summary>
[JsonPropertyName("save_to_db")]
public bool SaveToDb { get; set; }

/// <summary>
/// Code script name (e.g., demo.py)
/// </summary>
[JsonPropertyName("script_name")]
public string? ScriptName { get; set; }

/// <summary>
/// Code script type (i.e., src, test)
/// </summary>
[JsonPropertyName("script_type")]
public string? ScriptType { get; set; } = AgentCodeScriptType.Src;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace BotSharp.Abstraction.Coding.Responses;

public class CodeInterpretResponse
public class CodeInterpretResponse : ResponseBase
{
public string Result { get; set; } = string.Empty;
public bool Success { get; set; }
public string? ErrorMsg { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SelectFileOptions : LlmConfigBase
public string? TemplateName { get; set; }

/// <summary>
/// Description that user provides to select files
/// User description to select files
/// </summary>
public string? Description { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace BotSharp.Abstraction.Files.Responses;

public class FileHandleResponse
public class FileHandleResponse : ResponseBase
{
public string Result { get; set; } = string.Empty;
public bool Success { get; set; }
public string? ErrorMsg { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ namespace BotSharp.Abstraction.Instructs.Contexts;
public class CodeInstructContext
{
public string CodeScript { 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 @@ -2,14 +2,30 @@ namespace BotSharp.Abstraction.Instructs.Options;

public class CodeInstructOptions
{
/// <summary>
/// Code processor provider
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("processor")]
public string? Processor { get; set; }

/// <summary>
/// Code script name
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("code_script_name")]
public string? CodeScriptName { get; set; }
[JsonPropertyName("script_name")]
public string? ScriptName { get; set; }

/// <summary>
/// Code script name
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("script_type")]
public string? ScriptType { get; set; }

/// <summary>
/// Arguments
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("arguments")]
public List<KeyValue>? Arguments { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ namespace BotSharp.Abstraction.Instructs.Options;

public class FileInstructOptions
{
/// <summary>
/// File processor provider
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("processor")]
public string? Processor { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using BotSharp.Abstraction.MLTasks.Settings;

namespace BotSharp.Abstraction.MLTasks.Filters;

public class LlmConfigFilter
{
public List<string>? Providers { get; set; }
public List<string>? ModelIds { get; set; }
public List<string>? ModelNames { get; set; }
public List<LlmModelType>? ModelTypes { get; set; }
public List<LlmModelCapability>? ModelCapabilities { get; set; }
public bool? MultiModal { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using BotSharp.Abstraction.MLTasks.Filters;
using BotSharp.Abstraction.MLTasks.Settings;

namespace BotSharp.Abstraction.MLTasks;

public interface ILlmProviderService
{
LlmModelSetting GetSetting(string provider, string model);
LlmModelSetting? GetSetting(string provider, string model);
List<string> GetProviders();
LlmModelSetting GetProviderModel(string provider, string id, bool? multiModal = null, LlmModelType? modelType = null, bool imageGenerate = false);
LlmModelSetting? GetProviderModel(string provider, string id, bool? multiModal = null, LlmModelType? modelType = null, IEnumerable<LlmModelCapability>? capabilities = null);
List<LlmModelSetting> GetProviderModels(string provider);
List<LlmProviderSetting> GetLlmConfigs(LlmConfigOptions? options = null);
List<LlmProviderSetting> GetLlmConfigs(LlmConfigFilter? filter = null);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ public class LlmModelSetting
public string ApiKey { get; set; } = null!;
public string? Endpoint { get; set; }
public LlmModelType Type { get; set; } = LlmModelType.Chat;
public List<LlmModelCapability> Capabilities { get; set; } = [];

/// <summary>
/// If true, allow sending images/vidoes to this model
/// If true, allow sending images/videos to this model
/// </summary>
public bool MultiModal { get; set; }

/// <summary>
/// If true, allow generating images
/// </summary>
public bool ImageGeneration { get; set; }

/// <summary>
/// Settings for embedding
/// </summary>
Expand Down Expand Up @@ -173,10 +169,29 @@ public class LlmCostSetting

public enum LlmModelType
{
All = 0,
Text = 1,
Chat = 2,
Image = 3,
Embedding = 4,
Audio = 5,
Realtime = 6,
Web = 7
}

public enum LlmModelCapability
{
All = 0,
Text = 1,
Chat = 2,
ImageReading = 3,
ImageGeneration = 4,
ImageEdit = 5,
ImageVariation = 6,
Embedding = 7,
AudioTranscription = 8,
AudioGeneration = 9,
Realtime = 10,
WebSearch = 11,
PdfReading = 12
}
11 changes: 11 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Models/ResponseBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace BotSharp.Abstraction.Models;

public class ResponseBase
{
[JsonPropertyName("success")]
public bool Success { get; set; }

[JsonPropertyName("error_message")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ErrorMsg { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class AgentCodeScriptFilter

public static AgentCodeScriptFilter Empty()
{
return new AgentCodeScriptFilter();
return new();
}
}
Loading
Loading