integrate
This commit is contained in:
parent
872b57fa80
commit
710a1e19c2
|
|
@ -143,55 +143,29 @@ public class ConversationController : ControllerBase
|
|||
{
|
||||
var service = _services.GetRequiredService<IConversationService>();
|
||||
var userService = _services.GetRequiredService<IUserService>();
|
||||
var settings = _services.GetRequiredService<PluginSettings>();
|
||||
|
||||
var (isAdmin, user) = await userService.IsAdminUser(_user.Id);
|
||||
if (user == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var filter = new ConversationFilter
|
||||
{
|
||||
Id = conversationId,
|
||||
UserId = !isAdmin ? user.Id : null,
|
||||
UserId = !isAdmin ? user?.Id : null,
|
||||
IsLoadLatestStates = isLoadStates
|
||||
};
|
||||
|
||||
var conversations = await service.GetConversations(filter);
|
||||
if (conversations.Items.IsNullOrEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var conv = !conversations.Items.IsNullOrEmpty()
|
||||
? ConversationViewModel.FromSession(conversations.Items.First())
|
||||
: new();
|
||||
|
||||
var result = ConversationViewModel.FromSession(conversations.Items.First());
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
user = await userService.GetUser(result.User.Id);
|
||||
result.User = UserViewModel.FromUser(user);
|
||||
user = !string.IsNullOrEmpty(conv?.User?.Id)
|
||||
? await userService.GetUser(conv.User.Id)
|
||||
: null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost("/conversation/summary")]
|
||||
public async Task<string> GetConversationSummary([FromBody] ConversationSummaryModel input)
|
||||
{
|
||||
var service = _services.GetRequiredService<IConversationService>();
|
||||
return await service.GetConversationSummary(input.ConversationIds);
|
||||
}
|
||||
|
||||
[HttpGet("/conversation/{conversationId}/user")]
|
||||
public async Task<UserViewModel> GetConversationUser([FromRoute] string conversationId)
|
||||
{
|
||||
var service = _services.GetRequiredService<IConversationService>();
|
||||
var conversations = await service.GetConversations(new ConversationFilter
|
||||
{
|
||||
Id = conversationId
|
||||
});
|
||||
|
||||
var userService = _services.GetRequiredService<IUserService>();
|
||||
var conversation = conversations?.Items?.FirstOrDefault();
|
||||
var userId = conversation == null ? _user.Id : conversation.UserId;
|
||||
var user = await userService.GetUser(userId);
|
||||
if (user == null)
|
||||
{
|
||||
return new UserViewModel
|
||||
user = new User
|
||||
{
|
||||
Id = _user.Id,
|
||||
UserName = _user.UserName,
|
||||
|
|
@ -202,7 +176,16 @@ public class ConversationController : ControllerBase
|
|||
};
|
||||
}
|
||||
|
||||
return UserViewModel.FromUser(user);
|
||||
conv.User = UserViewModel.FromUser(user);
|
||||
conv.IsRealtimeEnabled = settings?.Assemblies?.Contains("BotSharp.Core.Realtime") ?? false;
|
||||
return conv;
|
||||
}
|
||||
|
||||
[HttpPost("/conversation/summary")]
|
||||
public async Task<string> GetConversationSummary([FromBody] ConversationSummaryModel input)
|
||||
{
|
||||
var service = _services.GetRequiredService<IConversationService>();
|
||||
return await service.GetConversationSummary(input.ConversationIds);
|
||||
}
|
||||
|
||||
[HttpPut("/conversation/{conversationId}/update-title")]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
using BotSharp.Abstraction.Conversations.Dtos;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BotSharp.OpenAPI.ViewModels.Conversations;
|
||||
|
||||
public class ConversationViewModel : ConversationDto
|
||||
{
|
||||
[JsonPropertyName("is_realtime_enabled")]
|
||||
public bool IsRealtimeEnabled { get; set; }
|
||||
|
||||
public static ConversationViewModel FromSession(Conversation sess)
|
||||
{
|
||||
return new ConversationViewModel
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class RealtimeSessionTurnDetection
|
|||
public string Type { get; set; } = "semantic_vad";
|
||||
|
||||
[JsonPropertyName("eagerness")]
|
||||
public string eagerness { get;set; } = "auto";
|
||||
public string Eagerness { get;set; } = "auto";
|
||||
}
|
||||
|
||||
public class InputAudioTranscription
|
||||
|
|
|
|||
Loading…
Reference in a new issue