diff --git a/BloggerAgent.Application/Dtos/MessageResponse.cs b/BloggerAgent.Application/Dtos/MessageResponse.cs index d7e98fc..e66d4a5 100644 --- a/BloggerAgent.Application/Dtos/MessageResponse.cs +++ b/BloggerAgent.Application/Dtos/MessageResponse.cs @@ -10,6 +10,6 @@ public class MessageResponse { public string Jsonrpc { get; set; } public string Id { get; set; } - public TaskMessage Result { get; set; } + public ResponseMessage Result { get; set; } } } diff --git a/BloggerAgent.Application/Dtos/TaskResponse.cs b/BloggerAgent.Application/Dtos/TaskResponse.cs index 064670a..93ada69 100644 --- a/BloggerAgent.Application/Dtos/TaskResponse.cs +++ b/BloggerAgent.Application/Dtos/TaskResponse.cs @@ -94,7 +94,26 @@ public class TaskResult public string Kind { get; set; } public Status Status { get; set; } public Artifact Artifacts { get; set; } - public List History { get; set; } + public List History { get; set; } + public Dictionary? Metadata { get; set; } + } + + public class ResponseMessage + { + public string? TaskId { get; set; } + public string MessageId { get; set; } + public string ContextId { get; set; } + public string Role { get; set; } + public string? Kind { get; set; } + public List Parts { get; set; } + public Dictionary? Metadata { get; set; } + + } + + public class MessageResponsePart + { + public string Kind { get; set; } // e.g., "text" + public string Text { get; set; } public Dictionary? Metadata { get; set; } } diff --git a/BloggerAgent.Application/Helpers/DataExtract.cs b/BloggerAgent.Application/Helpers/DataExtract.cs index ad90a91..e4b319a 100644 --- a/BloggerAgent.Application/Helpers/DataExtract.cs +++ b/BloggerAgent.Application/Helpers/DataExtract.cs @@ -1,4 +1,5 @@ -using BloggerAgent.Domain.Commons; +using BloggerAgent.Application.Dtos; +using BloggerAgent.Domain.Commons; using BloggerAgent.Domain.Models; using System; using System.Collections.Generic; @@ -59,5 +60,32 @@ public static string GetSettingValue(List settings, string key) { return settings.FirstOrDefault(s => s.Label == key)?.Default.ToString() ?? ""; } + + public static MessageResponse ConstructResponse(TaskRequest request, string response) + { + return new MessageResponse + { + Jsonrpc = "2.0", + Id = request.Id, + Result = new ResponseMessage() + { + Role = "agent", + Kind = "message", + MessageId = Guid.NewGuid().ToString(), + TaskId = request.Params.Message.TaskId, + ContextId = request.Params.Message.ContextId, + Parts = new List + { + new MessageResponsePart + { + Kind = "text", + Text = response, + } + }, + Metadata = null + + } + }; + } } } diff --git a/BloggerAgent.Application/Helpers/ValidationHelper.cs b/BloggerAgent.Application/Helpers/ValidationHelper.cs index 0934f11..b9cae2f 100644 --- a/BloggerAgent.Application/Helpers/ValidationHelper.cs +++ b/BloggerAgent.Application/Helpers/ValidationHelper.cs @@ -64,32 +64,7 @@ public static void ValidateRequest(TaskRequest request) } } - public static MessageResponse ConstructResponse(TaskRequest request, string response) - { - return new MessageResponse - { - Jsonrpc = "2.0", - Id = request.Id, - Result = new TaskMessage() - { - Role = "agent", - Kind = "message", - MessageId = Guid.NewGuid().ToString(), - TaskId = request.Params.Message.TaskId, - ContextId = request.Params.Message.ContextId, - Parts = new List - { - new MessagePart - { - Type = "text", - Text = response // ?? "Hi! Mike here, your blogger agent. I'm here to assist you with anyblogrelatedcontent.", - } - }, - Metadata = null - - } - }; - } + } } diff --git a/BloggerAgent.Infrastructure/Services/BlogAgentService.cs b/BloggerAgent.Infrastructure/Services/BlogAgentService.cs index 09203b3..92e06dc 100644 --- a/BloggerAgent.Infrastructure/Services/BlogAgentService.cs +++ b/BloggerAgent.Infrastructure/Services/BlogAgentService.cs @@ -69,7 +69,7 @@ public async Task HandleAsync(TaskRequest taskRequest) throw new Exception("Failed to generate response"); } - return ValidationHelper.ConstructResponse(taskRequest, aiResponse); + return DataExtract.ConstructResponse(taskRequest, aiResponse); } catch (Exception ex)