Skip to content

Commit 974a86c

Browse files
authored
Merge pull request #482 from iceljc/master
fix user cache
2 parents b77e77e + da850ea commit 974a86c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public async Task<string> GetConversationSummary(IEnumerable<string> conversatio
2727
contents.Add(content);
2828
}
2929

30+
if (contents.IsNullOrEmpty()) return string.Empty;
31+
3032
var router = await agentService.LoadAgent(AIAssistant);
3133
var prompt = GetPrompt(router, contents);
3234
var summary = await Summarize(router, prompt);
@@ -97,7 +99,12 @@ private string GetConversationContent(List<RoleDialogModel> dialogs, int maxDial
9799
foreach (var dialog in dialogs.TakeLast(maxDialogCount))
98100
{
99101
var role = dialog.Role;
100-
if (role != AgentRole.User && role != AgentRole.Assistant) continue;
102+
if (role == AgentRole.Function) continue;
103+
104+
if (role != AgentRole.User)
105+
{
106+
role = AgentRole.Assistant;
107+
}
101108

102109
conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n";
103110
}

src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public async Task<User> GetMyProfile()
217217
return user;
218218
}
219219

220-
[MemoryCache(10 * 60)]
220+
[MemoryCache(10 * 60, perInstanceCache: true)]
221221
public async Task<User> GetUser(string id)
222222
{
223223
var db = _services.GetRequiredService<IBotSharpRepository>();

0 commit comments

Comments
 (0)