Skip to content

Commit 27e0c4b

Browse files
committed
Filter by conversation id.
1 parent 56224d1 commit 27e0c4b

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

src/Infrastructure/BotSharp.Abstraction/Users/Enums/UserRole.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ public class UserRole
1616
/// Client
1717
/// </summary>
1818
public const string Client = "client";
19+
20+
/// <summary>
21+
/// AI Assistant
22+
/// </summary>
23+
public const string Assistant = "assistant";
1924
}

src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,11 @@ public List<Conversation> GetConversations(ConversationFilter filter)
799799
if (record == null) continue;
800800

801801
var matched = true;
802-
if (!string.IsNullOrEmpty(filter.AgentId)) matched = matched && record.AgentId == filter.AgentId;
803-
if (!string.IsNullOrEmpty(filter.Status)) matched = matched && record.Status == filter.Status;
804-
if (!string.IsNullOrEmpty(filter.Channel)) matched = matched && record.Channel == filter.Channel;
805-
if (!string.IsNullOrEmpty(filter.UserId)) matched = matched && record.UserId == filter.UserId;
802+
if(filter.Id != null) matched = matched && record.Id == filter.Id;
803+
if (filter.AgentId != null) matched = matched && record.AgentId == filter.AgentId;
804+
if (filter.Status != null) matched = matched && record.Status == filter.Status;
805+
if (filter.Channel != null) matched = matched && record.Channel == filter.Channel;
806+
if (filter.UserId != null) matched = matched && record.UserId == filter.UserId;
806807

807808
if (!matched) continue;
808809
records.Add(record);

src/Infrastructure/BotSharp.Logger/Hooks/VerboseLogHook.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task BeforeGenerating(Agent agent, List<RoleDialogModel> conversati
2424
if (!_convSettings.ShowVerboseLog) return;
2525

2626
var dialog = conversations.Last();
27-
var log = $"[msg_id: {dialog.MessageId}] {dialog.Role}: {dialog.Content}";
27+
var log = $"{dialog.Role}: {dialog.Content} [msg_id: {dialog.MessageId}] ==>";
2828
_logger.LogInformation(log);
2929

3030
await Task.CompletedTask;
@@ -38,8 +38,8 @@ public async Task AfterGenerated(RoleDialogModel message, TokenStatsModel tokenS
3838
var agent = await agentService.LoadAgent(message.CurrentAgentId);
3939

4040
var log = message.Role == AgentRole.Function ?
41-
$"[[msg_id: {message.MessageId}] [{agent?.Name}]: {message.FunctionName}({message.FunctionArgs})" :
42-
$"[[msg_id: {message.MessageId}] [{agent?.Name}]: {message.Content}";
41+
$"[{agent?.Name}]: {message.FunctionName}({message.FunctionArgs})" :
42+
$"[{agent?.Name}]: {message.Content}" + $" <== [msg_id: {message.MessageId}]";
4343

4444
_logger.LogInformation(tokenStats.Prompt);
4545
_logger.LogInformation(log);

src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ public async Task<ConversationViewModel> GetConversation([FromRoute] string conv
9393
var userService = _services.GetRequiredService<IUserService>();
9494
var result = ConversationViewModel.FromSession(conversations.Items.First());
9595

96+
var state = _services.GetRequiredService<IConversationStateService>();
97+
result.States = state.Load(conversationId);
98+
9699
var user = await userService.GetUser(result.User.Id);
97100
result.User = UserViewModel.FromUser(user);
98101

src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/ConversationViewModel.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using BotSharp.Abstraction.Conversations.Enums;
2-
using BotSharp.Abstraction.Conversations.Models;
3-
using BotSharp.OpenAPI.ViewModels.Users;
41
using System.Text.Json.Serialization;
52

63
namespace BotSharp.OpenAPI.ViewModels.Conversations;
@@ -23,6 +20,7 @@ public class ConversationViewModel
2320

2421
public string Channel { get; set; } = ConversationChannel.OpenAPI;
2522
public string Status { get; set; }
23+
public ConversationState States { get; set; }
2624

2725
[JsonPropertyName("updated_time")]
2826
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;

0 commit comments

Comments
 (0)