feat: add LanceDB vector database provider
- Implemented LanceDBProvider for managing vector collections, including methods for creating, deleting, and searching collections. - Added support for LanceDB configuration in VectorDBConfig. - Introduced stub for LanceDB provider when not built with the appropriate tag. - Updated provider initialization to include LanceDB as a supported type. - Created types and interfaces for vector operations, including Vector, SearchRequest, and SearchResult. - Added tests for VectorDBConfig unmarshalling and for ensuring proper error handling when LanceDB is not built. - Updated enums to include LanceDB type and labels. - Modified frontend enums to reflect the addition of LanceDB.
This commit is contained in:
@@ -123,14 +123,22 @@ type OSSStorageConfig struct {
|
||||
}
|
||||
|
||||
type VectorDBConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
Type string `yaml:"type"`
|
||||
Qdrant QdrantVectorDBConfig `yaml:"qdrant"`
|
||||
LanceDB LanceDBVectorDBConfig `yaml:"lancedb"`
|
||||
}
|
||||
|
||||
type QdrantVectorDBConfig struct {
|
||||
Host string `yaml:"host"`
|
||||
Port int `yaml:"port"`
|
||||
APIKey string `yaml:"apiKey"`
|
||||
GrpcPort int `yaml:"grpcPort"`
|
||||
APIKey string `yaml:"apiKey"`
|
||||
UseTLS bool `yaml:"useTls"`
|
||||
}
|
||||
|
||||
type LanceDBVectorDBConfig struct {
|
||||
Path string `yaml:"path"`
|
||||
}
|
||||
|
||||
type MCPConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Servers map[string]MCPServerConfig `yaml:"servers"`
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestVectorDBConfigUnmarshalNestedProviders(t *testing.T) {
|
||||
raw := []byte(`
|
||||
vectorDB:
|
||||
type: lancedb
|
||||
qdrant:
|
||||
host: 127.0.0.1
|
||||
grpcPort: 6334
|
||||
apiKey: secret
|
||||
useTls: true
|
||||
lancedb:
|
||||
path: data/lancedb
|
||||
`)
|
||||
|
||||
var cfg Config
|
||||
if err := yaml.Unmarshal(raw, &cfg); err != nil {
|
||||
t.Fatalf("yaml.Unmarshal() error = %v", err)
|
||||
}
|
||||
|
||||
if cfg.VectorDB.Type != "lancedb" {
|
||||
t.Fatalf("VectorDB.Type = %q, want %q", cfg.VectorDB.Type, "lancedb")
|
||||
}
|
||||
if cfg.VectorDB.Qdrant.Host != "127.0.0.1" {
|
||||
t.Fatalf("VectorDB.Qdrant.Host = %q, want %q", cfg.VectorDB.Qdrant.Host, "127.0.0.1")
|
||||
}
|
||||
if cfg.VectorDB.Qdrant.GrpcPort != 6334 {
|
||||
t.Fatalf("VectorDB.Qdrant.GrpcPort = %d, want %d", cfg.VectorDB.Qdrant.GrpcPort, 6334)
|
||||
}
|
||||
if cfg.VectorDB.Qdrant.APIKey != "secret" {
|
||||
t.Fatalf("VectorDB.Qdrant.APIKey = %q, want %q", cfg.VectorDB.Qdrant.APIKey, "secret")
|
||||
}
|
||||
if !cfg.VectorDB.Qdrant.UseTLS {
|
||||
t.Fatal("VectorDB.Qdrant.UseTLS = false, want true")
|
||||
}
|
||||
if cfg.VectorDB.LanceDB.Path != "data/lancedb" {
|
||||
t.Fatalf("VectorDB.LanceDB.Path = %q, want %q", cfg.VectorDB.LanceDB.Path, "data/lancedb")
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,13 @@ package enums
|
||||
type VectorDBType string
|
||||
|
||||
const (
|
||||
VectorDBTypeQdrant VectorDBType = "qdrant"
|
||||
VectorDBTypeQdrant VectorDBType = "qdrant"
|
||||
VectorDBTypeLanceDB VectorDBType = "lancedb"
|
||||
)
|
||||
|
||||
var vectorDBTypeLabelMap = map[VectorDBType]string{
|
||||
VectorDBTypeQdrant: "Qdrant",
|
||||
VectorDBTypeQdrant: "Qdrant",
|
||||
VectorDBTypeLanceDB: "LanceDB",
|
||||
}
|
||||
|
||||
func GetVectorDBTypeLabel(dbType VectorDBType) string {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package enums
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestVectorDBTypeLabelIncludesLanceDB(t *testing.T) {
|
||||
if VectorDBTypeLanceDB != "lancedb" {
|
||||
t.Fatalf("VectorDBTypeLanceDB = %q, want %q", VectorDBTypeLanceDB, "lancedb")
|
||||
}
|
||||
if got := GetVectorDBTypeLabel(VectorDBTypeLanceDB); got != "LanceDB" {
|
||||
t.Fatalf("GetVectorDBTypeLabel(VectorDBTypeLanceDB) = %q, want %q", got, "LanceDB")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user