Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<PackageVersion Include="Sdcb.PaddleOCR" Version="2.7.0.1" />
<PackageVersion Include="Sdcb.PaddleOCR.Models.LocalV3" Version="2.7.0.1" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.14" />
<PackageVersion Include="pythonnet" Version="3.0.4" />
<PackageVersion Include="pythonnet" Version="3.0.5" />
<PackageVersion Include="Qdrant.Client" Version="1.15.0" />
<PackageVersion Include="Selenium.WebDriver" Version="4.27.0" />
<PackageVersion Include="HtmlAgilityPack" Version="1.12.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace BotSharp.Abstraction.Agents.Enums;

public static class AgentCodeScriptType
{
public const string Src = "src";
public const string Test = "test";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Agents.Enums;

public class AgentFuncVisMode
public static class AgentFuncVisMode
{
public const string Manual = "manual";
public const string Auto = "auto";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Agents.Enums;

public class AgentRole
public static class AgentRole
{
public const string System = "system";
public const string Assistant = "assistant";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Agents.Enums;

public class AgentType
public static class AgentType
{
/// <summary>
/// Routing agent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Agents.Enums;

public class BuiltInAgentId
public static class BuiltInAgentId
{
/// <summary>
/// A routing agent can be used as a base router.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public interface IAgentService
/// <param name="agent"></param>
/// <returns></returns>
Task<string> PatchAgentTemplate(Agent agent);
Task<string> UpdateAgentFromFile(string id);
string GetDataDir();
string GetAgentDataDir(string agentId);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace BotSharp.Abstraction.Agents.Models;

public class AgentCodeScript : AgentCodeScriptBase
{
public string Id { get; set; }
public string AgentId { get; set; } = null!;

public AgentCodeScript() : base()
{
}

public override string ToString()
{
return $"{CodePath}";
}
}

public class AgentCodeScriptBase
{
public string Name { get; set; } = null!;
public string Content { get; set; } = null!;

/// <summary>
/// Code script type: src, test
/// </summary>
public string ScriptType { get; set; } = null!;

public string CodePath => $"{ScriptType}/{Name}";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BotSharp.Abstraction.CodeInterpreter.Models;

namespace BotSharp.Abstraction.CodeInterpreter;

public interface ICodeInterpretService
{
string Provider { get; }

Task<CodeInterpretResult> RunCode(string codeScript, CodeInterpretOptions? options = null)
=> throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BotSharp.Abstraction.CodeInterpreter.Models;

public class CodeInterpretOptions
{
public IEnumerable<KeyValue>? Arguments { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BotSharp.Abstraction.CodeInterpreter.Models;

public class CodeInterpretResult
{
public object Result { get; set; }
public bool Success { get; set; }
public string? ErrorMsg { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Conversations.Enums;

public class ConversationChannel
public static class ConversationChannel
{
public const string WebChat = "webchat";
public const string OpenAPI = "openapi";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Conversations.Enums;

public class ConversationStatus
public static class ConversationStatus
{
public const string Open = "open";
public const string Closed = "closed";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Conversations.Enums;

public class StateDataType
public static class StateDataType
{
public const string String = "string";
public const string Boolean = "boolean";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Conversations.Enums;

public class StateSource
public static class StateSource
{
public const string External = "external";
public const string Application = "application";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ public class RoleDialogModel : ITrackableMessage
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public bool IsFromAssistant => Role == AgentRole.Assistant || Role == AgentRole.Model;

[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public string RoleContent
{
get
{
var text = Content;
if (Role == AgentRole.User)
{
text = !string.IsNullOrWhiteSpace(Payload) ? Payload : Content;
}
else
{
text = !string.IsNullOrWhiteSpace(RichContent?.Message?.Text) ? RichContent.Message.Text : Content;
}

return text;
}
}

public RoleDialogModel()
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Infrastructures.Enums;

public class LanguageType
public static class LanguageType
{
public const string UNKNOWN = "Unknown";
public const string ENGLISH = "English";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Infrastructures.Enums;

public class StateConst
public static class StateConst
{
public const string EXPECTED_ACTION_AGENT = "expected_next_action_agent";
public const string EXPECTED_GOAL_AGENT = "expected_user_goal_agent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ namespace BotSharp.Abstraction.Instructs;

public interface IInstructHook : IHookBase
{
Task BeforeCompletion(Agent agent, RoleDialogModel message);
Task AfterCompletion(Agent agent, InstructResult result);
Task OnResponseGenerated(InstructResponseModel response);
Task BeforeCompletion(Agent agent, RoleDialogModel message) => Task.CompletedTask;
Task AfterCompletion(Agent agent, InstructResult result) => Task.CompletedTask;
Task OnResponseGenerated(InstructResponseModel response) => Task.CompletedTask;

Task BeforeCodeExecution(Agent agent, RoleDialogModel message, CodeInstructContext context) => Task.CompletedTask;
Task AfterCodeExecution(Agent agent, InstructResult result) => Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ public interface IInstructService
/// <summary>
/// Execute completion by using specified instruction or template
/// </summary>
/// <param name="agentId">Agent (static agent)</param>
/// <param name="message">Additional message provided by user</param>
/// <param name="templateName">Template name</param>
/// <param name="instruction">System prompt</param>
/// <param name="agentId"></param>
/// <param name="message"></param>
/// <param name="instruction"></param>
/// <param name="templateName"></param>
/// <param name="files"></param>
/// <param name="codeOptions"></param>
/// <returns></returns>
Task<InstructResult> Execute(string agentId, RoleDialogModel message,
string? templateName = null, string? instruction = null, IEnumerable<InstructFileModel>? files = null);
string? instruction = null, string? templateName = null,
IEnumerable<InstructFileModel>? files = null, CodeInstructOptions? codeOptions = null);

/// <summary>
/// A generic way to execute completion by using specified instruction or template
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace BotSharp.Abstraction.Instructs.Models;

public class CodeInstructContext
{
public string CodeScript { get; set; }
public List<KeyValue> Arguments { get; set; } = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BotSharp.Abstraction.Instructs.Models;

public class CodeInstructOptions
{
public string? CodeScriptName { get; set; }
public string? CodeInterpretProvider { get; set; }
public List<KeyValue>? Arguments { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public class InstructResult : ITrackableMessage
public string MessageId { get; set; }
public string Text { get; set; } = string.Empty;
public object? Data { get; set; }

[JsonPropertyName("template")]
public string? Template{ get; set; }
public string? Template { get; set; }
public Dictionary<string, string>? States { get; set; } = new();
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface IRealTimeCompletion
string Provider { get; }
string Model { get; }
void SetModelName(string model);
void SetOptions(RealtimeOptions? options);

Task Connect(
RealtimeHubConnection conn,
Expand Down
11 changes: 11 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Models/KeyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ public class KeyValue
[JsonPropertyName("value")]
public string? Value { get; set; }

public KeyValue()
{

}

public KeyValue(string key, string? value)
{
Key = key;
Value = value;
}

public override string ToString()
{
return $"Key: {Key}, Value: {Value}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public interface IRealtimeHub

IRealTimeCompletion Completer { get; }

Task ConnectToModel(Func<string, Task>? responseToUser = null, Func<string, Task>? init = null, List<MessageState>? initStates = null);
Task ConnectToModel(Func<string, Task>? responseToUser = null, Func<string, Task>? init = null,
List<MessageState>? initStates = null, RealtimeOptions? options = null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace BotSharp.Abstraction.Realtime.Models;

public class RealtimeOptions
{
[JsonPropertyName("input_audio_format")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? InputAudioFormat { get; set; }

[JsonPropertyName("output_audio_format")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? OutputAudioFormat { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace BotSharp.Abstraction.Repositories.Filters;

public class AgentCodeScriptFilter
{
public List<string>? ScriptNames { get; set; }
public List<string>? ScriptTypes { get; set; }

public static AgentCodeScriptFilter Empty()
{
return new AgentCodeScriptFilter();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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 46 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 46 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 46 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 46 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 46 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 46 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 @@ -85,7 +85,6 @@
=> throw new NotImplementedException();
bool PatchAgentTemplate(string agentId, AgentTemplate template)
=> throw new NotImplementedException();

bool UpdateAgentLabels(string agentId, List<string> labels)
=> throw new NotImplementedException();
bool AppendAgentLabels(string agentId, List<string> labels)
Expand All @@ -99,13 +98,24 @@
=> throw new NotImplementedException();
void InsertAgentTask(AgentTask task)
=> throw new NotImplementedException();
void BulkInsertAgentTasks(List<AgentTask> tasks)
void BulkInsertAgentTasks(string agentId, List<AgentTask> tasks)
=> throw new NotImplementedException();
void UpdateAgentTask(AgentTask task, AgentTaskField field)
=> throw new NotImplementedException();
bool DeleteAgentTask(string agentId, List<string> taskIds)
bool DeleteAgentTasks(string agentId, List<string>? taskIds = null)
=> throw new NotImplementedException();
#endregion

#region Agent Code
List<AgentCodeScript> GetAgentCodeScripts(string agentId, AgentCodeScriptFilter? filter = null)
=> throw new NotImplementedException();
string? GetAgentCodeScript(string agentId, string scriptName, string scriptType = AgentCodeScriptType.Src)
=> throw new NotImplementedException();
bool UpdateAgentCodeScripts(string agentId, List<AgentCodeScript> scripts)
=> throw new NotImplementedException();
bool BulkInsertAgentCodeScripts(string agentId, List<AgentCodeScript> scripts)
=> throw new NotImplementedException();
bool DeleteAgentTasks()
bool DeleteAgentCodeScripts(string agentId, List<AgentCodeScript>? scripts = null)
=> throw new NotImplementedException();
#endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Routing.Enums;

public class RoutingMode
public static class RoutingMode
{
public const string Eager = "eager";
public const string Lazy = "lazy";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BotSharp.Abstraction.Routing.Enums;

public class RuleType
public static class RuleType
{
/// <summary>
/// Fallback to redirect agent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <summary>
/// Agent task status
/// </summary>
public class TaskStatus
public static class TaskStatus
{
public const string Scheduled = "scheduled";
public const string New = "new";
Expand Down
Loading
Loading