Skip to content

Commit ad7d9a1

Browse files
committed
reso
2 parents 9b9c588 + 4d153b1 commit ad7d9a1

File tree

65 files changed

+2025
-631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2025
-631
lines changed

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
os:
16+
- ubuntu-latest
17+
- windows-latest
18+
- macos-latest
19+
runs-on: ${{matrix.os}}
20+
steps:
21+
- uses: actions/checkout@v1
22+
- name: Setup .NET Core
23+
uses: actions/setup-dotnet@v3
24+
with:
25+
dotnet-version: '8.0.x'
26+
- name: Set env
27+
run: |
28+
echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $GITHUB_ENV
29+
echo "DOTNET_hostBuilder:reloadConfigOnChange=false" >> $GITHUB_ENV
30+
- name: Install required workloads
31+
run: |
32+
dotnet workload install aspire --source https://aka.ms/dotnet8/nuget/index.json --source https://api.nuget.org/v3/index.json
33+
- name: Clean
34+
run: |
35+
dotnet clean ./BotSharp.sln --configuration Release
36+
dotnet nuget locals all --clear
37+
- name: Build
38+
run: dotnet build ./BotSharp.sln -c Release
39+
- name: Test
40+
run: |
41+
cd ./tests/UnitTest
42+
dotnet test --logger "console;verbosity=detailed"
43+
cd ../BotSharp.Plugin.SemanticKernel.UnitTests
44+
dotnet test --logger "console;verbosity=detailed"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The core module is mainly composed of abstraction and framework function impleme
7474

7575
### Plugins
7676

77-
BotSharp uses component design, the kernel is kept to a minimum, and business functions are implemented by external components. The modular design also allows contributors to better participate. Below are the bulit-in plugins:
77+
BotSharp uses component design, the kernel is kept to a minimum, and business functions are implemented by external components. The modular design also allows contributors to better participate. Below are the built-in plugins:
7878

7979
#### Data Storages
8080
- BotSharp.Core.Repository

src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
</ItemGroup>
2626

2727
<ItemGroup>
28+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
2829
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" />
2930
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" />
3031
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />

src/Infrastructure/BotSharp.Abstraction/Conversations/Enums/MessageTypeName.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ public static class MessageTypeName
44
{
55
public const string Plain = "plain";
66
public const string Notification = "notification";
7+
public const string FunctionCall = "function";
8+
public const string Audio = "audio";
79
}

src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,13 @@ Task<bool> SendMessage(string agentId,
6363
bool IsConversationMode();
6464

6565
void SaveStates();
66+
67+
/// <summary>
68+
/// Get conversation keys for searching
69+
/// </summary>
70+
/// <param name="query">search query</param>
71+
/// <param name="convLimit">conversation limit</param>
72+
/// <param name="preLoad">if pre-loading, then keys are not filter by the search query</param>
73+
/// <returns></returns>
74+
Task<List<string>> GetConversationStateSearhKeys(string query, int convlimit = 100, int keyLimit = 10, bool preLoad = false);
6675
}

src/Infrastructure/BotSharp.Abstraction/Infrastructures/Enums/StateConst.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ public class StateConst
1010
public const string AGENT_REDIRECTION_REASON = "agent_redirection_reason";
1111

1212
public const string LANGUAGE = "language";
13+
14+
public const string SUB_CONVERSATION_ID = "sub_conversation_id";
1315
}

src/Infrastructure/BotSharp.Abstraction/MLTasks/IRealTimeCompletion.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,28 @@ namespace BotSharp.Abstraction.MLTasks;
55
public interface IRealTimeCompletion
66
{
77
string Provider { get; }
8+
string Model { get; }
89

910
void SetModelName(string model);
1011

12+
Task Connect(RealtimeHubConnection conn,
13+
Action onModelReady,
14+
Action<string> onModelAudioDeltaReceived,
15+
Action onModelAudioResponseDone,
16+
Action<string> onAudioTranscriptDone,
17+
Action<List<RoleDialogModel>> onModelResponseDone,
18+
Action<string> onConversationItemCreated,
19+
Action<RoleDialogModel> onInputAudioTranscriptionCompleted,
20+
Action onUserInterrupted);
21+
Task AppenAudioBuffer(string message);
22+
23+
Task SendEventToModel(object message);
24+
Task Disconnect();
25+
1126
Task<RealtimeSession> CreateSession(Agent agent, List<RoleDialogModel> conversations);
27+
Task UpdateInitialSession(RealtimeHubConnection conn);
28+
Task InsertConversationItem(RoleDialogModel message);
29+
Task TriggerModelInference(string? instructions = null);
30+
Task<List<RoleDialogModel>> OnResponsedDone(RealtimeHubConnection conn, string response);
31+
Task<RoleDialogModel> OnConversationItemCreated(RealtimeHubConnection conn, string response);
1232
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using BotSharp.Abstraction.Realtime.Models;
2+
using System.Net.WebSockets;
3+
4+
namespace BotSharp.Abstraction.Realtime;
5+
6+
/// <summary>
7+
/// Realtime hub interface. Manage the WebSocket connection include User, Agent and Model.
8+
/// </summary>
9+
public interface IRealtimeHub
10+
{
11+
Task Listen(WebSocket userWebSocket, Func<string, RealtimeHubConnection> onUserMessageReceived);
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace BotSharp.Abstraction.Realtime.Models;
2+
3+
public class RealtimeHubConnection
4+
{
5+
public string Event { get; set; } = null!;
6+
public string StreamId { get; set; } = null!;
7+
public string EntryAgentId { get; set; } = null!;
8+
public string ConversationId { get; set; } = null!;
9+
public string Data { get; set; } = string.Empty;
10+
public string Model { get; set; } = null!;
11+
public Func<string, object> OnModelMessageReceived { get; set; } = null!;
12+
public Func<object> OnModelAudioResponseDone { get; set; } = null!;
13+
public Func<object> OnModelUserInterrupted { get; set; } = null!;
14+
}

src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ List<Conversation> GetLastConversations()
146146
=> throw new NotImplementedException();
147147
List<string> GetIdleConversations(int batchSize, int messageLimit, int bufferHours, IEnumerable<string> excludeAgentIds)
148148
=> throw new NotImplementedException();
149-
IEnumerable<string> TruncateConversation(string conversationId, string messageId, bool cleanLog = false)
149+
List<string> TruncateConversation(string conversationId, string messageId, bool cleanLog = false)
150+
=> throw new NotImplementedException();
151+
List<string> GetConversationStateSearchKeys(int messageLowerLimit = 2, int convUpperlimit = 100)
150152
=> throw new NotImplementedException();
151153
#endregion
152154

0 commit comments

Comments
 (0)