diff --git a/src/Infrastructure/BotSharp.Abstraction/Translation/Models/TranslationOutput.cs b/src/Infrastructure/BotSharp.Abstraction/Translation/Models/TranslationOutput.cs index 52ad54ec8..b15bfef45 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Translation/Models/TranslationOutput.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Translation/Models/TranslationOutput.cs @@ -9,5 +9,5 @@ public class TranslationOutput public string OutputLanguage { get; set; } = LanguageType.ENGLISH; [JsonPropertyName("texts")] - public string[] Texts { get; set; } = Array.Empty(); + public TranslationInput[] Texts { get; set; } = Array.Empty(); } diff --git a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs index 5c60e1089..e51497519 100644 --- a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs +++ b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs @@ -79,7 +79,7 @@ public async Task Translate(Agent router, string messageId, T data, string for (var i = 0; i < texts.Count; i++) { - map[keys[i]] = translatedTexts[i]; + map[keys[i]] = translatedTexts[i].Text; } clonedData = Assign(clonedData, map); diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs index a1d2ca3ed..80374a6dd 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs @@ -257,7 +257,11 @@ public async Task SendMessageSse([FromRoute] string agentId, conv.SetConversationId(conversationId, input.States); SetStates(conv, input); - var response = new ChatResponseModel(); + var response = new ChatResponseModel + { + ConversationId = conversationId, + MessageId = inputMsg.MessageId, + }; Response.StatusCode = 200; Response.Headers.Append(Microsoft.Net.Http.Headers.HeaderNames.ContentType, "text/event-stream"); @@ -266,6 +270,7 @@ public async Task SendMessageSse([FromRoute] string agentId, await conv.SendMessage(agentId, inputMsg, replyMessage: input.Postback, + // responsed generated async msg => { response.Text = !string.IsNullOrEmpty(msg.SecondaryContent) ? msg.SecondaryContent : msg.Content; @@ -274,18 +279,21 @@ await conv.SendMessage(agentId, inputMsg, response.Instruction = msg.Instruction; response.Data = msg.Data; - await OnChunkReceived(Response, msg); + await OnChunkReceived(Response, response); }, + // executing async msg => { - var message = new RoleDialogModel(AgentRole.Function, msg.Content) + var indicator = new ChatResponseModel { - FunctionArgs = msg.FunctionArgs, - FunctionName = msg.FunctionName, - Indication = msg.Indication + ConversationId = conversationId, + MessageId = msg.MessageId, + Text = msg.Indication, + Function = "indicating", }; - await OnChunkReceived(Response, message); + await OnChunkReceived(Response, indicator); }, + // executed async msg => { @@ -299,7 +307,7 @@ await conv.SendMessage(agentId, inputMsg, // await OnEventCompleted(Response); } - private async Task OnChunkReceived(HttpResponse response, RoleDialogModel message) + private async Task OnChunkReceived(HttpResponse response, ChatResponseModel message) { var json = JsonSerializer.Serialize(message);