Merge remote-tracking branch 'github_public/main'
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/elastic/go-elasticsearch/v8"
|
||||
"github.com/neo4j/neo4j-go-driver/v6/neo4j"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/dig"
|
||||
"gorm.io/driver/postgres"
|
||||
@@ -28,6 +29,7 @@ import (
|
||||
elasticsearchRepoV8 "github.com/Tencent/WeKnora/internal/application/repository/retriever/elasticsearch/v8"
|
||||
neo4jRepo "github.com/Tencent/WeKnora/internal/application/repository/retriever/neo4j"
|
||||
postgresRepo "github.com/Tencent/WeKnora/internal/application/repository/retriever/postgres"
|
||||
qdrantRepo "github.com/Tencent/WeKnora/internal/application/repository/retriever/qdrant"
|
||||
"github.com/Tencent/WeKnora/internal/application/service"
|
||||
chatpipline "github.com/Tencent/WeKnora/internal/application/service/chat_pipline"
|
||||
"github.com/Tencent/WeKnora/internal/application/service/file"
|
||||
@@ -421,6 +423,54 @@ func initRetrieveEngineRegistry(db *gorm.DB, cfg *config.Config) (interfaces.Ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if slices.Contains(retrieveDriver, "qdrant") {
|
||||
qdrantHost := os.Getenv("QDRANT_HOST")
|
||||
if qdrantHost == "" {
|
||||
qdrantHost = "localhost"
|
||||
}
|
||||
|
||||
qdrantPort := 6334 // Default port
|
||||
if portStr := os.Getenv("QDRANT_PORT"); portStr != "" {
|
||||
if port, err := strconv.Atoi(portStr); err == nil {
|
||||
qdrantPort = port
|
||||
}
|
||||
}
|
||||
|
||||
// API key for authentication (optional)
|
||||
qdrantAPIKey := os.Getenv("QDRANT_API_KEY")
|
||||
|
||||
// TLS configuration (optional, defaults to false)
|
||||
// Enable TLS unless explicitly set to "false" or "0" (case insensitive)
|
||||
qdrantUseTLS := false
|
||||
if useTLSStr := os.Getenv("QDRANT_USE_TLS"); useTLSStr != "" {
|
||||
useTLSLower := strings.ToLower(strings.TrimSpace(useTLSStr))
|
||||
qdrantUseTLS = useTLSLower != "false" && useTLSLower != "0"
|
||||
}
|
||||
|
||||
log.Infof("Connecting to Qdrant at %s:%d (TLS: %v)", qdrantHost, qdrantPort, qdrantUseTLS)
|
||||
|
||||
client, err := qdrant.NewClient(&qdrant.Config{
|
||||
Host: qdrantHost,
|
||||
Port: qdrantPort,
|
||||
APIKey: qdrantAPIKey,
|
||||
UseTLS: qdrantUseTLS,
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("Create qdrant client failed: %v", err)
|
||||
} else {
|
||||
qdrantRepository := qdrantRepo.NewQdrantRetrieveEngineRepository(client)
|
||||
if err := registry.Register(
|
||||
retriever.NewKVHybridRetrieveEngine(
|
||||
qdrantRepository, types.QdrantRetrieverEngineType,
|
||||
),
|
||||
); err != nil {
|
||||
log.Errorf("Register qdrant retrieve engine failed: %v", err)
|
||||
} else {
|
||||
log.Infof("Register qdrant retrieve engine success")
|
||||
}
|
||||
}
|
||||
}
|
||||
return registry, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user