chuns erhoeht

This commit is contained in:
Christoph K.
2026-03-12 19:24:14 +01:00
parent 75003b9534
commit 3c8d3873dc

View File

@@ -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 }