Skip to content

Commit 04eafed

Browse files
author
Jicheng Lu
committed
refine transcription
1 parent d9fe6da commit 04eafed

17 files changed

Lines changed: 328 additions & 427 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using BotSharp.Abstraction.Realtime.Models;
2-
using System;
3-
using static System.Runtime.InteropServices.JavaScript.JSType;
42

53
namespace BotSharp.Abstraction.MLTasks;
64

@@ -20,6 +18,7 @@ Task Connect(
2018
Func<string, Task> onConversationItemCreated,
2119
Func<RoleDialogModel, Task> onInputAudioTranscriptionDone,
2220
Func<Task> onInterruptionDetected);
21+
2322
Task AppenAudioBuffer(string message);
2423
Task AppenAudioBuffer(ArraySegment<byte> data, int length);
2524

@@ -31,6 +30,4 @@ Task Connect(
3130
Task RemoveConversationItem(string itemId);
3231
Task TriggerModelInference(string? instructions = null);
3332
Task CancelModelResponse();
34-
Task<List<RoleDialogModel>> OnResponsedDone(RealtimeHubConnection conn, string response);
35-
Task<RoleDialogModel> OnConversationItemCreated(RealtimeHubConnection conn, string response);
3633
}

src/Infrastructure/BotSharp.Abstraction/Realtime/Models/RealtimeModelSettings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ public class RealtimeModelSettings
1212
public string Voice { get; set; } = "alloy";
1313
public float Temperature { get; set; } = 0.8f;
1414
public int MaxResponseOutputTokens { get; set; } = 512;
15-
public int ModelResponseTimeout { get; set; } = 30;
15+
public int ModelResponseTimeoutSeconds { get; set; } = 30;
16+
17+
/// <summary>
18+
/// Whether the target event arrives after ModelResponseTimeoutSeconds, e.g., "response.done"
19+
/// </summary>
20+
public string? ModelResponseTimeoutEndEvent { get; set; }
1621
public AudioTranscription InputAudioTranscription { get; set; } = new();
1722
public ModelTurnDetection TurnDetection { get; set; } = new();
1823
}

src/Infrastructure/BotSharp.Core.Realtime/Hooks/RealtimeConversationHook.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public async Task OnFunctionExecuted(RoleDialogModel message)
4242
var routing = _services.GetRequiredService<IRoutingService>();
4343

4444
message.Role = AgentRole.Function;
45+
//message.Role = AgentRole.Assistant;
4546

4647
if (message.FunctionName == "route_to_agent")
4748
{

src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@
211211
<Content Include="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\functions\get_weather.json">
212212
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
213213
</Content>
214-
<Content Include="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\functions\get_location.json">
215-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
216-
</Content>
217214
</ItemGroup>
218215

219216
<ItemGroup>

src/Infrastructure/BotSharp.Core/Functions/GetWeatherFn.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public GetWeatherFn(IServiceProvider services)
2020

2121
public async Task<bool> Execute(RoleDialogModel message)
2222
{
23-
var args = JsonSerializer.Deserialize<Location>(message.FunctionArgs, BotSharpOptions.defaultJsonOptions);
23+
//var args = JsonSerializer.Deserialize<Location>(message.FunctionArgs, BotSharpOptions.defaultJsonOptions);
2424

25-
var sidecar = _services.GetService<IConversationSideCar>();
26-
var states = GetSideCarStates();
25+
//var sidecar = _services.GetService<IConversationSideCar>();
26+
//var states = GetSideCarStates();
2727

28-
var userMessage = $"Please find the information at location {args.City}, {args.State}";
29-
var response = await sidecar.SendMessage(BuiltInAgentId.Chatbot, userMessage, states: states);
30-
message.Content = $"It is a sunny day {response.Content}.";
28+
//var userMessage = $"Please find the information at location {args.City}, {args.State}";
29+
//var response = await sidecar.SendMessage(BuiltInAgentId.Chatbot, userMessage, states: states);
30+
message.Content = $"It is a sunny day.";
3131
return true;
3232
}
3333

src/Infrastructure/BotSharp.Core/Infrastructures/Websocket/AsyncWebsocketDataResultEnumerator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using BotSharp.Abstraction.Realtime.Models.Session;
21
using System.Buffers;
32
using System.ClientModel;
43
using System.Net.WebSockets;

src/Infrastructure/BotSharp.Core/Session/BotSharpRealtimeSession.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private ChatSessionUpdate HandleSessionResult(ClientResult result)
5555
};
5656
}
5757

58-
public async Task SendEvent(string message)
58+
public async Task SendEventAsync(string message)
5959
{
6060
if (_websocket.State == WebSocketState.Open)
6161
{
@@ -64,7 +64,7 @@ public async Task SendEvent(string message)
6464
}
6565
}
6666

67-
public async Task Disconnect()
67+
public async Task DisconnectAsync()
6868
{
6969
if (_websocket.State == WebSocketState.Open)
7070
{

src/Infrastructure/BotSharp.Core/Session/LlmRealtimeSession.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private ChatSessionUpdate HandleSessionResult(ClientResult result)
7171
};
7272
}
7373

74-
public async Task SendEventToModel(object message)
74+
public async Task SendEventToModelAsync(object message)
7575
{
7676
if (_webSocket.State != WebSocketState.Open)
7777
{
@@ -96,7 +96,7 @@ public async Task SendEventToModel(object message)
9696
}
9797
}
9898

99-
public async Task Disconnect()
99+
public async Task DisconnectAsync()
100100
{
101101
if (_webSocket.State == WebSocketState.Open)
102102
{

src/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/functions/get_location.json

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
{
22
"name": "get_weather",
33
"description": "Get weather information for user.",
4-
"visibility_expression": "{% if states.channel != 'email' %}visible{% endif %}",
54
"parameters": {
65
"type": "object",
76
"properties": {
87
"city": {
98
"type": "string",
109
"description": "The city where the user wants to get weather information."
11-
},
12-
"state": {
13-
"type": "string",
14-
"description": "The state where the user wants to get weather information."
1510
}
1611
},
17-
"required": [ "city", "state" ]
12+
"required": [ "city" ]
1813
}
1914
}

0 commit comments

Comments
 (0)