fix init states

This commit is contained in:
Jicheng Lu 2025-04-17 16:07:59 -05:00
parent dcc2fd1bbb
commit db99c2dd33
2 changed files with 22 additions and 7 deletions

View file

@ -368,8 +368,8 @@ public class ConversationController : ControllerBase
var routing = _services.GetRequiredService<IRoutingService>();
routing.Context.SetMessageId(conversationId, inputMsg.MessageId);
SetStates(conv, input);
conv.SetConversationId(conversationId, input.States);
SetStates(conv, input);
var response = new ChatResponseModel();
@ -581,11 +581,26 @@ public class ConversationController : ControllerBase
#region Private methods
private void SetStates(IConversationService conv, NewMessageModel input)
{
conv.States.SetState("channel", input.Channel, source: StateSource.External)
.SetState("provider", input.Provider, source: StateSource.External)
.SetState("model", input.Model, source: StateSource.External)
.SetState("temperature", input.Temperature, source: StateSource.External)
.SetState("sampling_factor", input.SamplingFactor, source: StateSource.External);
if (string.IsNullOrEmpty(conv.States.GetState("channel")))
{
conv.States.SetState("channel", input.Channel, source: StateSource.External);
}
if (string.IsNullOrEmpty(conv.States.GetState("provider")))
{
conv.States.SetState("provider", input.Provider, source: StateSource.External);
}
if (string.IsNullOrEmpty(conv.States.GetState("model")))
{
conv.States.SetState("model", input.Model, source: StateSource.External);
}
if (string.IsNullOrEmpty(conv.States.GetState("temperature")))
{
conv.States.SetState("temperature", input.Temperature, source: StateSource.External);
}
if (string.IsNullOrEmpty(conv.States.GetState("sampling_factor")))
{
conv.States.SetState("sampling_factor", input.SamplingFactor, source: StateSource.External);
}
}
private FileContentResult BuildFileResult(string file)

View file

@ -38,7 +38,7 @@ public class RealtimeChatSession : IDisposable
public async IAsyncEnumerable<SessionConversationUpdate> ReceiveUpdatesAsync([EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await foreach (ClientResult result in ReceiveInnerUpdatesAsync())
await foreach (ClientResult result in ReceiveInnerUpdatesAsync(cancellationToken))
{
var update = HandleSessionResult(result);
yield return update;