Merge pull request #482 from iceljc/master

fix user cache
This commit is contained in:
C. Oceania 2024-05-30 23:13:04 -05:00 committed by GitHub
commit 974a86cb66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -27,6 +27,8 @@ public partial class ConversationService
contents.Add(content);
}
if (contents.IsNullOrEmpty()) return string.Empty;
var router = await agentService.LoadAgent(AIAssistant);
var prompt = GetPrompt(router, contents);
var summary = await Summarize(router, prompt);
@ -97,7 +99,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>();