Merge pull request #1015 from iceljc/Development

fix init states
This commit is contained in:
iceljc 2025-04-17 17:30:08 -05:00 committed by GitHub
commit 485e170967
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 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

@ -24,6 +24,7 @@ public class AsyncWebsocketDataResultEnumerator : IAsyncEnumerator<ClientResult>
public ValueTask DisposeAsync()
{
ArrayPool<byte>.Shared.Return(_buffer, clearArray: true);
_webSocket?.Dispose();
return new ValueTask(Task.CompletedTask);
}

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;