Skip to content

Commit bc35112

Browse files
authored
Merge pull request #1169 from iceljc/features/refine-model-settings
Features/refine model settings
2 parents a283af0 + defa629 commit bc35112

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

src/Infrastructure/BotSharp.Core.SideCar/Services/BotSharpConversationSideCar.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ limitations under the License.
1515
******************************************************************************/
1616

1717
using BotSharp.Core.Infrastructures;
18-
using NetTopologySuite.Index.KdTree;
19-
using Newtonsoft.Json.Linq;
20-
using static System.Runtime.InteropServices.JavaScript.JSType;
2118

2219
namespace BotSharp.Core.SideCar.Services;
2320

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ You may obtain a copy of the License at
1414
limitations under the License.
1515
******************************************************************************/
1616

17-
using BotSharp.Abstraction.Conversations.Enums;
18-
using BotSharp.Abstraction.Hooks;
1917
using BotSharp.Abstraction.Options;
2018
using BotSharp.Abstraction.SideCar;
2119

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public async Task<bool> Execute(RoleDialogModel message)
3737
await Task.Delay(1500);
3838

3939
#if DEBUG
40-
var temp = RoleDialogModel.From(message, AgentRole.Assistant, $"Here is your weather in {args?.City}");
40+
var intermediateMsg = RoleDialogModel.From(message, AgentRole.Assistant, $"Here is your weather in {args?.City}");
4141
messageHub.Push(new()
4242
{
4343
EventName = ChatEvent.OnIntermediateMessageReceivedFromAssistant,
44-
Data = temp,
44+
Data = intermediateMsg,
4545
RefId = conv.ConversationId,
4646
SaveDataToDb = true
4747
});

src/Infrastructure/BotSharp.Core/MessageHub/Observers/ConversationObserver.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public override void OnError(Exception error)
3030
public override void OnNext(HubObserveData<RoleDialogModel> value)
3131
{
3232
var conv = _services.GetRequiredService<IConversationService>();
33+
var storage = _services.GetRequiredService<IConversationStorage>();
34+
var routeCtx = _services.GetRequiredService<IRoutingContext>();
3335

3436
if (value.EventName == ChatEvent.OnIndicationReceived)
3537
{
@@ -41,5 +43,16 @@ public override void OnNext(HubObserveData<RoleDialogModel> value)
4143
func(value).ConfigureAwait(false).GetAwaiter().GetResult();
4244
}
4345
}
46+
else if (value.EventName == ChatEvent.OnIntermediateMessageReceivedFromAssistant)
47+
{
48+
var dialogs = routeCtx.GetDialogs();
49+
dialogs.Add(value.Data);
50+
routeCtx.SetDialogs(dialogs);
51+
52+
if (value.SaveDataToDb)
53+
{
54+
storage.Append(conv.ConversationId, value.Data);
55+
}
56+
}
4457
}
4558
}

src/Plugins/BotSharp.Plugin.ChatHub/Observers/ChatHubObserver.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ public override void OnNext(HubObserveData<RoleDialogModel> value)
140140
Role = AgentRole.Assistant
141141
}
142142
};
143-
144-
if (value.SaveDataToDb)
145-
{
146-
var storage = _services.GetRequiredService<IConversationStorage>();
147-
storage.Append(conv.ConversationId, message);
148-
}
149143
break;
150144
}
151145

0 commit comments

Comments
 (0)