Add Sender in ChatResponse.

This commit is contained in:
Haiping Chen 2023-11-13 22:56:06 -06:00
parent 7824622385
commit 5ca1203ff5
4 changed files with 16 additions and 4 deletions

View file

@ -72,7 +72,7 @@ public class ConversationController : ControllerBase, IApiAdapter
}
[HttpPost("/conversation/{agentId}/{conversationId}")]
public async Task<MessageResponseModel> SendMessage([FromRoute] string agentId,
public async Task<ChatResponseModel> SendMessage([FromRoute] string agentId,
[FromRoute] string conversationId,
[FromBody] NewMessageModel input)
{
@ -84,7 +84,7 @@ public class ConversationController : ControllerBase, IApiAdapter
.SetState("temperature", input.Temperature)
.SetState("sampling_factor", input.SamplingFactor);
var response = new MessageResponseModel();
var response = new ChatResponseModel();
var inputMsg = new RoleDialogModel("user", input.Text);
await conv.SendMessage(agentId, inputMsg,
async msg =>

View file

@ -1,11 +1,17 @@
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Instructs.Models;
using BotSharp.OpenAPI.ViewModels.Users;
using System.Text.Json.Serialization;
namespace BotSharp.OpenAPI.ViewModels.Conversations;
public class MessageResponseModel : InstructResult
public class ChatResponseModel : InstructResult
{
[JsonPropertyName("conversation_id")]
public string ConversationId { get; set; }
public UserViewModel Sender { get; set; }
public string Function { get; set; }
/// <summary>
@ -20,4 +26,6 @@ public class MessageResponseModel : InstructResult
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("rich_content")]
public object? RichContent { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}

View file

@ -9,6 +9,7 @@ public class ConversationViewModel
public string AgentId { get; set; }
public string Title { get; set; } = string.Empty;
public UserViewModel User { get; set; } = new UserViewModel();
public int UnreadMsgCount { get; set; }
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;

View file

@ -1,3 +1,4 @@
using BotSharp.Abstraction.Users.Enums;
using BotSharp.Abstraction.Users.Models;
namespace BotSharp.OpenAPI.ViewModels.Users;
@ -8,6 +9,7 @@ public class UserViewModel
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Role { get; set; } = UserRole.Client;
public string FullName => $"{FirstName} {LastName}";
@ -18,7 +20,8 @@ public class UserViewModel
Id = user.Id,
FirstName = user.FirstName,
LastName = user.LastName,
Email = user.Email
Email = user.Email,
Role = user.Role
};
}
}