feat: Auto-Context im Frontend anzeigen und in DB persistieren
- recalled_context-Header verstärkt (klare Nutzungs-Anweisung statt passivem Hinweis) - SSE-Event 'auto_context' ans Frontend senden für Live-Anzeige - Auto-Context als Message (type=auto_context) in DB speichern - Aufklappbare Auto-Context-Box im Chat-Stream und History-Rendering Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f2baa1639
commit
9fe6bed59b
6 files changed
+67
-1
No files matched your search
@@ -64,7 +64,17 @@ public partial class AnthropicService
|
||||
{
|
||||
var autoCtx = await BuildAutoContextAsync(messages, chainId, agentId);
|
||||
if (autoCtx != null)
|
||||
{
|
||||
systemPrompt.Add(new { type = "text", text = autoCtx });
|
||||
await SseHelper.TryWriteSse(response, "auto_context", new { context = autoCtx }, sseCt);
|
||||
await _db.SaveMessage(new MessageRecord
|
||||
{
|
||||
ChainId = chainId,
|
||||
Role = "system",
|
||||
Type = "auto_context",
|
||||
Content = autoCtx
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -190,7 +190,7 @@ public partial class AnthropicService
|
||||
|
||||
var ctxSb = new StringBuilder();
|
||||
ctxSb.AppendLine("\n<recalled_context>");
|
||||
ctxSb.AppendLine("Die folgende Information wurde automatisch abgerufen und könnte relevant sein:");
|
||||
ctxSb.AppendLine("WICHTIG: Der folgende Kontext wurde automatisch per Vektor-Suche aus früheren Gesprächen und Memory abgerufen. Prüfe diesen Kontext ZUERST, bevor du antwortest. Wenn er zur aktuellen Frage passt, beziehe dich aktiv darauf und nutze die Informationen in deiner Antwort. Ignoriere ihn nur, wenn er eindeutig irrelevant ist.");
|
||||
foreach (var r in contextResults)
|
||||
{
|
||||
var date = DateTime.TryParse(r.CreatedAt, out var dt) ? dt.ToString("yyyy-MM-dd HH:mm") : r.CreatedAt;
|
||||
|
||||
Reference in new issue
Block a user