fix user cache

This commit is contained in:
Jicheng Lu 2024-05-30 22:47:07 -05:00
parent b77e77e310
commit c0cd2387a2
2 changed files with 7 additions and 2 deletions

View file

@ -97,7 +97,12 @@ public partial class ConversationService
foreach (var dialog in dialogs.TakeLast(maxDialogCount))
{
var role = dialog.Role;
if (role != AgentRole.User && role != AgentRole.Assistant) continue;
if (role == AgentRole.Function) continue;
if (role != AgentRole.User)
{
role = AgentRole.Assistant;
}
conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n";
}

View file

@ -217,7 +217,7 @@ public class UserService : IUserService
return user;
}
[MemoryCache(10 * 60)]
[MemoryCache(10 * 60, perInstanceCache: true)]
public async Task<User> GetUser(string id)
{
var db = _services.GetRequiredService<IBotSharpRepository>();