Add Sender in ChatResponse.
This commit is contained in:
parent
7824622385
commit
5ca1203ff5
|
|
@ -72,7 +72,7 @@ public class ConversationController : ControllerBase, IApiAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/conversation/{agentId}/{conversationId}")]
|
[HttpPost("/conversation/{agentId}/{conversationId}")]
|
||||||
public async Task<MessageResponseModel> SendMessage([FromRoute] string agentId,
|
public async Task<ChatResponseModel> SendMessage([FromRoute] string agentId,
|
||||||
[FromRoute] string conversationId,
|
[FromRoute] string conversationId,
|
||||||
[FromBody] NewMessageModel input)
|
[FromBody] NewMessageModel input)
|
||||||
{
|
{
|
||||||
|
|
@ -84,7 +84,7 @@ public class ConversationController : ControllerBase, IApiAdapter
|
||||||
.SetState("temperature", input.Temperature)
|
.SetState("temperature", input.Temperature)
|
||||||
.SetState("sampling_factor", input.SamplingFactor);
|
.SetState("sampling_factor", input.SamplingFactor);
|
||||||
|
|
||||||
var response = new MessageResponseModel();
|
var response = new ChatResponseModel();
|
||||||
var inputMsg = new RoleDialogModel("user", input.Text);
|
var inputMsg = new RoleDialogModel("user", input.Text);
|
||||||
await conv.SendMessage(agentId, inputMsg,
|
await conv.SendMessage(agentId, inputMsg,
|
||||||
async msg =>
|
async msg =>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
using BotSharp.Abstraction.Functions.Models;
|
using BotSharp.Abstraction.Functions.Models;
|
||||||
using BotSharp.Abstraction.Instructs.Models;
|
using BotSharp.Abstraction.Instructs.Models;
|
||||||
|
using BotSharp.OpenAPI.ViewModels.Users;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace BotSharp.OpenAPI.ViewModels.Conversations;
|
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; }
|
public string Function { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -20,4 +26,6 @@ public class MessageResponseModel : InstructResult
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
[JsonPropertyName("rich_content")]
|
[JsonPropertyName("rich_content")]
|
||||||
public object? RichContent { get; set; }
|
public object? RichContent { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
@ -9,6 +9,7 @@ public class ConversationViewModel
|
||||||
public string AgentId { get; set; }
|
public string AgentId { get; set; }
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
public UserViewModel User { get; set; } = new UserViewModel();
|
public UserViewModel User { get; set; } = new UserViewModel();
|
||||||
|
public int UnreadMsgCount { get; set; }
|
||||||
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
|
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
|
||||||
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using BotSharp.Abstraction.Users.Enums;
|
||||||
using BotSharp.Abstraction.Users.Models;
|
using BotSharp.Abstraction.Users.Models;
|
||||||
|
|
||||||
namespace BotSharp.OpenAPI.ViewModels.Users;
|
namespace BotSharp.OpenAPI.ViewModels.Users;
|
||||||
|
|
@ -8,6 +9,7 @@ public class UserViewModel
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
|
public string Role { get; set; } = UserRole.Client;
|
||||||
|
|
||||||
public string FullName => $"{FirstName} {LastName}";
|
public string FullName => $"{FirstName} {LastName}";
|
||||||
|
|
||||||
|
|
@ -18,7 +20,8 @@ public class UserViewModel
|
||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
FirstName = user.FirstName,
|
FirstName = user.FirstName,
|
||||||
LastName = user.LastName,
|
LastName = user.LastName,
|
||||||
Email = user.Email
|
Email = user.Email,
|
||||||
|
Role = user.Role
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue