feat: Semantische Suche über Chat-History (memory_search)
- Lokales Embedding-Model (all-MiniLM-L6-v2, ONNX, CPU) - EmbeddingService: WordPiece-Tokenizer + Mean Pooling (384 Dim) - VectorSearchService: SQLite-basierte Vektor-Speicherung + Cosine Similarity - EmbeddingBackgroundService: Backfill bestehender Messages + Live-Queue - Neues Tool memory_search: Semantische Suche über alle Sessions (inkl. archivierte) - ~9000 Messages embedded, Suche über komplette Chat-History
This commit is contained in:
1 parent
baf53b7dac
commit
add111ffe1
9 files changed
+727
-15
No files matched your search
@@ -22,7 +22,7 @@ public static class ChatEndpoint
|
||||
app.MapPost("/api/chat/stop", HandleStop);
|
||||
}
|
||||
|
||||
private static async Task HandleChat(HttpRequest req, HttpResponse res, IConfiguration config, ChatService chatService, DatabaseService db, StreamingTracker streamingTracker, AnthropicService anthropic, RemoteConnectionManager remoteMgr, CancellationToken cancellationToken)
|
||||
private static async Task HandleChat(HttpRequest req, HttpResponse res, IConfiguration config, ChatService chatService, DatabaseService db, StreamingTracker streamingTracker, AnthropicService anthropic, RemoteConnectionManager remoteMgr, EmbeddingBackgroundService embeddingBg, CancellationToken cancellationToken)
|
||||
{
|
||||
var body = await JsonSerializer.DeserializeAsync<ChatRequest>(req.Body);
|
||||
if (body == null)
|
||||
@@ -108,7 +108,7 @@ public static class ChatEndpoint
|
||||
Data = b.Data
|
||||
}).ToList();
|
||||
|
||||
await db.SaveMessageWithAttachments(new MessageRecord
|
||||
var userMsgId = await db.SaveMessageWithAttachments(new MessageRecord
|
||||
{
|
||||
ChainId = ctx.ChainId,
|
||||
Iteration = 0,
|
||||
@@ -116,6 +116,7 @@ public static class ChatEndpoint
|
||||
Type = "text",
|
||||
Content = textContent
|
||||
}, attachmentRecords);
|
||||
embeddingBg?.Enqueue(userMsgId, ctx.ChainId, ctx.SessionId, ctx.AgentId, "user", textContent ?? "");
|
||||
}
|
||||
|
||||
res.Headers["Content-Type"] = "text/event-stream";
|
||||
|
||||
Reference in new issue
Block a user