mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-30 16:38:31 +02:00
+45
@@ -0,0 +1,45 @@
|
|||||||
|
```go
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/qdrant/go-client/qdrant"
|
||||||
|
)
|
||||||
|
|
||||||
|
client, err := qdrant.NewClient(&qdrant.Config{
|
||||||
|
Host: "xyz-example.qdrant.io",
|
||||||
|
Port: 6334,
|
||||||
|
APIKey: "<paste-your-api-key-here>",
|
||||||
|
UseTLS: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
client.Query(ctx, &qdrant.QueryPoints{
|
||||||
|
CollectionName: "{collection_name}",
|
||||||
|
Prefetch: []*qdrant.PrefetchQuery{
|
||||||
|
{
|
||||||
|
Query: qdrant.NewQueryNearest(
|
||||||
|
qdrant.NewVectorInputDocument(&qdrant.Document{
|
||||||
|
Model: "openai/text-embedding-3-small",
|
||||||
|
Text: "How to bake cookies?",
|
||||||
|
Options: qdrant.NewValueMap(map[string]any{
|
||||||
|
"mrl": 64,
|
||||||
|
"openai-api-key": "<YOUR_OPENAI_API_KEY>",
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
Using: qdrant.PtrOf("small"),
|
||||||
|
Limit: qdrant.PtrOf(uint64(1000)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Query: qdrant.NewQueryNearest(
|
||||||
|
qdrant.NewVectorInputDocument(&qdrant.Document{
|
||||||
|
Model: "openai/text-embedding-3-small",
|
||||||
|
Text: "How to bake cookies?",
|
||||||
|
Options: qdrant.NewValueMap(map[string]any{
|
||||||
|
"openai-api-key": "<YOUR_OPENAI_API_KEY>",
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
Using: qdrant.PtrOf("large"),
|
||||||
|
Limit: qdrant.PtrOf(uint64(10)),
|
||||||
|
})
|
||||||
|
```
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
```go
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/qdrant/go-client/qdrant"
|
||||||
|
)
|
||||||
|
|
||||||
|
client, err := qdrant.NewClient(&qdrant.Config{
|
||||||
|
Host: "xyz-example.qdrant.io",
|
||||||
|
Port: 6334,
|
||||||
|
APIKey: "<paste-your-api-key-here>",
|
||||||
|
UseTLS: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
client.Upsert(ctx, &qdrant.UpsertPoints{
|
||||||
|
CollectionName: "{collection_name}",
|
||||||
|
Points: []*qdrant.PointStruct{
|
||||||
|
{
|
||||||
|
Id: qdrant.NewIDNum(uint64(1)),
|
||||||
|
Vectors: qdrant.NewVectorsMap(map[string]*qdrant.Vector{
|
||||||
|
"large": qdrant.NewVectorDocument(&qdrant.Document{
|
||||||
|
Model: "openai/text-embedding-3-small",
|
||||||
|
Text: "Recipe for baking chocolate chip cookies",
|
||||||
|
Options: qdrant.NewValueMap(map[string]any{
|
||||||
|
"openai-api-key": "<YOUR_OPENAI_API_KEY>",
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
"small": qdrant.NewVectorDocument(&qdrant.Document{
|
||||||
|
Model: "openai/text-embedding-3-small",
|
||||||
|
Text: "Recipe for baking chocolate chip cookies",
|
||||||
|
Options: qdrant.NewValueMap(map[string]any{
|
||||||
|
"openai-api-key": "<YOUR_OPENAI_API_KEY>",
|
||||||
|
"mrl": 64,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user