Filter by conversation id.

This commit is contained in:
Haiping Chen 2023-12-27 13:27:52 -06:00
parent 56224d16c8
commit 27e0c4b307
5 changed files with 17 additions and 10 deletions

View file

@ -16,4 +16,9 @@ public class UserRole
/// Client
/// </summary>
public const string Client = "client";
/// <summary>
/// AI Assistant
/// </summary>
public const string Assistant = "assistant";
}

View file

@ -799,10 +799,11 @@ public class FileRepository : IBotSharpRepository
if (record == null) continue;
var matched = true;
if (!string.IsNullOrEmpty(filter.AgentId)) matched = matched && record.AgentId == filter.AgentId;
if (!string.IsNullOrEmpty(filter.Status)) matched = matched && record.Status == filter.Status;
if (!string.IsNullOrEmpty(filter.Channel)) matched = matched && record.Channel == filter.Channel;
if (!string.IsNullOrEmpty(filter.UserId)) matched = matched && record.UserId == filter.UserId;
if(filter.Id != null) matched = matched && record.Id == filter.Id;
if (filter.AgentId != null) matched = matched && record.AgentId == filter.AgentId;
if (filter.Status != null) matched = matched && record.Status == filter.Status;
if (filter.Channel != null) matched = matched && record.Channel == filter.Channel;
if (filter.UserId != null) matched = matched && record.UserId == filter.UserId;
if (!matched) continue;
records.Add(record);

View file

@ -24,7 +24,7 @@ public class VerboseLogHook : IContentGeneratingHook
if (!_convSettings.ShowVerboseLog) return;
var dialog = conversations.Last();
var log = $"[msg_id: {dialog.MessageId}] {dialog.Role}: {dialog.Content}";
var log = $"{dialog.Role}: {dialog.Content} [msg_id: {dialog.MessageId}] ==>";
_logger.LogInformation(log);
await Task.CompletedTask;
@ -38,8 +38,8 @@ public class VerboseLogHook : IContentGeneratingHook
var agent = await agentService.LoadAgent(message.CurrentAgentId);
var log = message.Role == AgentRole.Function ?
$"[[msg_id: {message.MessageId}] [{agent?.Name}]: {message.FunctionName}({message.FunctionArgs})" :
$"[[msg_id: {message.MessageId}] [{agent?.Name}]: {message.Content}";
$"[{agent?.Name}]: {message.FunctionName}({message.FunctionArgs})" :
$"[{agent?.Name}]: {message.Content}" + $" <== [msg_id: {message.MessageId}]";
_logger.LogInformation(tokenStats.Prompt);
_logger.LogInformation(log);

View file

@ -93,6 +93,9 @@ public class ConversationController : ControllerBase
var userService = _services.GetRequiredService<IUserService>();
var result = ConversationViewModel.FromSession(conversations.Items.First());
var state = _services.GetRequiredService<IConversationStateService>();
result.States = state.Load(conversationId);
var user = await userService.GetUser(result.User.Id);
result.User = UserViewModel.FromUser(user);

View file

@ -1,6 +1,3 @@
using BotSharp.Abstraction.Conversations.Enums;
using BotSharp.Abstraction.Conversations.Models;
using BotSharp.OpenAPI.ViewModels.Users;
using System.Text.Json.Serialization;
namespace BotSharp.OpenAPI.ViewModels.Conversations;
@ -23,6 +20,7 @@ public class ConversationViewModel
public string Channel { get; set; } = ConversationChannel.OpenAPI;
public string Status { get; set; }
public ConversationState States { get; set; }
[JsonPropertyName("updated_time")]
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;