From 3c8d3873dc3eebae0efe6b8771d48cc225f1259a Mon Sep 17 00:00:00 2001 From: "Christoph K." Date: Thu, 12 Mar 2026 19:24:14 +0100 Subject: [PATCH] chuns erhoeht --- internal/brain/ingest.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/brain/ingest.go b/internal/brain/ingest.go index 9786053..6f6ace1 100755 --- a/internal/brain/ingest.go +++ b/internal/brain/ingest.go @@ -234,7 +234,8 @@ func ingestChunks(ctx context.Context, embClient *openai.Client, pointsClient pb return err } -// IngestChatMessage speichert eine einzelne Chat-Nachricht in Qdrant. +// IngestChatMessage speichert eine Chat-Nachricht in Qdrant. +// Lange Nachrichten (> maxChunkSize) werden automatisch aufgeteilt. func IngestChatMessage(text, author, source string) error { ctx := context.Background() ctx = metadata.AppendToOutgoingContext(ctx, "api-key", config.Cfg.Qdrant.APIKey) @@ -246,9 +247,12 @@ func IngestChatMessage(text, author, source string) error { ensureCollection(ctx, pb.NewCollectionsClient(conn)) pointsClient := pb.NewPointsClient(conn) - fullText := fmt.Sprintf("[%s] %s", author, text) - c := chunk{Text: fullText, Source: source, Type: "chat"} - return ingestChunks(ctx, embClient, pointsClient, []chunk{c}) + prefix := fmt.Sprintf("[%s] ", author) + var chunks []chunk + for _, part := range splitLongSection(text) { + chunks = append(chunks, chunk{Text: prefix + part, Source: source, Type: "chat"}) + } + return ingestChunks(ctx, embClient, pointsClient, chunks) } func boolPtr(b bool) *bool { return &b }