mirror of
https://github.com/hanzoai/vector-go.git
synced 2026-10-30 18:18:35 +00:00
Update module path and all imports from github.com/qdrant/go-client to github.com/hanzoai/vector-go for Hanzo Vector Go SDK.
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/hanzoai/vector-go/qdrant"
|
|
)
|
|
|
|
const (
|
|
collectionName = "test_collection"
|
|
)
|
|
|
|
func main() {
|
|
// Create context
|
|
ctx := context.Background()
|
|
|
|
// Create new client
|
|
client, err := qdrant.NewClient(&qdrant.Config{
|
|
Host: "localhost", // Can be omitted, default is "localhost"
|
|
Port: 6334, // Can be omitted, default is 6334
|
|
// APIKey: "<API_KEY>",
|
|
// UseTLS: true,
|
|
// TLSConfig: &tls.Config{},
|
|
// GrpcOptions: []grpc.DialOption{},
|
|
})
|
|
if err != nil {
|
|
log.Fatalf("Failed to create client: %v", err)
|
|
}
|
|
defer client.Close()
|
|
|
|
err = client.CreateCollection(ctx, &qdrant.CreateCollection{
|
|
CollectionName: collectionName,
|
|
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
|
Size: uint64(128),
|
|
Distance: qdrant.Distance_Cosine,
|
|
}),
|
|
})
|
|
|
|
if err != nil {
|
|
log.Printf("Could not create collection: %v", err)
|
|
return
|
|
}
|
|
|
|
collections, err := client.ListCollections(ctx)
|
|
if err != nil {
|
|
log.Printf("Could not list collections: %v", err)
|
|
return
|
|
}
|
|
log.Printf("List of collections: %+v", collections)
|
|
}
|