zwischenstand
This commit is contained in:
@@ -256,3 +256,30 @@ func IngestChatMessage(text, author, source string) error {
|
||||
}
|
||||
|
||||
func boolPtr(b bool) *bool { return &b }
|
||||
|
||||
// IngestText speichert einen beliebigen Text mit Quelle und Typ in Qdrant.
|
||||
// Verwendet die gleiche Chunking-Logik wie der Markdown-Ingest.
|
||||
func IngestText(text, source, docType string) error {
|
||||
ctx := context.Background()
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "api-key", config.Cfg.Qdrant.APIKey)
|
||||
|
||||
embClient := config.NewEmbeddingClient()
|
||||
conn := config.NewQdrantConn()
|
||||
defer conn.Close()
|
||||
|
||||
ensureCollection(ctx, pb.NewCollectionsClient(conn))
|
||||
pointsClient := pb.NewPointsClient(conn)
|
||||
|
||||
var chunks []chunk
|
||||
for _, part := range splitLongSection(text) {
|
||||
part = strings.TrimSpace(part)
|
||||
if len(part) < 20 {
|
||||
continue
|
||||
}
|
||||
chunks = append(chunks, chunk{Text: part, Source: source, Type: docType})
|
||||
}
|
||||
if len(chunks) == 0 {
|
||||
return nil
|
||||
}
|
||||
return ingestChunks(ctx, embClient, pointsClient, chunks)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user