feat: Add Qdrant client's retrieve_points functionality
- Added a new `retrieve_points` function to the Qdrant client to retrieve points by their IDs. This allows for efficient fetching of specific points from a collection. - Renamed `is_exists` to `is_collection_exists` for clarity and consistency. - Added `RetrievePointsRequest`, `RetrievePointsParams`, and `RetrievePointsResponse` structs for better structured data.
This commit is contained in:
@@ -40,7 +40,19 @@ list_collection := qdrant_client.list_collections()!
|
||||
println('List Collection: ${list_collection}')
|
||||
|
||||
// 6. Check collection existence
|
||||
collection_existence := qdrant_client.is_exists(
|
||||
collection_existence := qdrant_client.is_collection_exists(
|
||||
collection_name: collection_name
|
||||
)!
|
||||
println('Collection Existence: ${collection_existence}')
|
||||
|
||||
// 7. Retrieve points
|
||||
collection_points := qdrant_client.retrieve_points(
|
||||
collection_name: collection_name
|
||||
ids: [
|
||||
0,
|
||||
3,
|
||||
100,
|
||||
]
|
||||
)!
|
||||
|
||||
println('Collection Points: ${collection_points}')
|
||||
|
||||
@@ -194,7 +194,7 @@ pub mut:
|
||||
}
|
||||
|
||||
// Check collection existence
|
||||
pub fn (mut self QDrantClient) is_exists(params CollectionExistenceParams) !QDrantResponse[CollectionExistenceResponse] {
|
||||
pub fn (mut self QDrantClient) is_collection_exists(params CollectionExistenceParams) !QDrantResponse[CollectionExistenceResponse] {
|
||||
mut http_conn := self.httpclient()!
|
||||
req := httpconnection.Request{
|
||||
method: .get
|
||||
|
||||
51
lib/clients/qdrant/points.v
Normal file
51
lib/clients/qdrant/points.v
Normal file
@@ -0,0 +1,51 @@
|
||||
module qdrant
|
||||
|
||||
import freeflowuniverse.herolib.core.httpconnection
|
||||
import json
|
||||
|
||||
// Retrieves all details from multiple points.
|
||||
pub struct RetrievePointsRequest {
|
||||
pub mut:
|
||||
ids []int @[json: 'ids'; required] // Look for points with ids
|
||||
shard_key string // Specify in which shards to look for the points, if not specified - look in all shards
|
||||
with_payload bool // Select which payload to return with the response. Default is true.
|
||||
with_vectors bool // Options for specifying which vectors to include into response. Default is false.
|
||||
}
|
||||
|
||||
// Retrieves all details from multiple points.
|
||||
@[params]
|
||||
pub struct RetrievePointsParams {
|
||||
pub mut:
|
||||
ids []int @[json: 'ids'; required] // Look for points with ids
|
||||
collection_name string @[json: 'collection_name'; required] // Name of the collection
|
||||
shard_key string // Specify in which shards to look for the points, if not specified - look in all shards
|
||||
with_payload bool // Select which payload to return with the response. Default is true.
|
||||
with_vectors bool // Options for specifying which vectors to include into response. Default is false.
|
||||
}
|
||||
|
||||
pub struct RetrievePointsResponse {
|
||||
pub mut:
|
||||
id int // Type, used for specifying point ID in user interface
|
||||
payload map[string]string // Payload - values assigned to the point
|
||||
vector []f64 // Vector of the point
|
||||
shard_id string // Shard name
|
||||
order_value f64 // Order value
|
||||
}
|
||||
|
||||
// Retrieves all details from multiple points.
|
||||
pub fn (mut self QDrantClient) retrieve_points(params RetrievePointsParams) !QDrantResponse[RetrievePointsResponse] {
|
||||
mut http_conn := self.httpclient()!
|
||||
req := httpconnection.Request{
|
||||
method: .post
|
||||
prefix: '/collections/${params.collection_name}/points'
|
||||
data: json.encode(RetrievePointsRequest{
|
||||
ids: params.ids
|
||||
shard_key: params.shard_key
|
||||
with_payload: params.with_payload
|
||||
with_vectors: params.with_vectors
|
||||
})
|
||||
}
|
||||
|
||||
mut response := http_conn.send(req)!
|
||||
return json.decode(QDrantResponse[RetrievePointsResponse], response.data)!
|
||||
}
|
||||
@@ -3,7 +3,6 @@ module qdrant
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.encoderhero
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
pub const version = '1.13.4'
|
||||
const singleton = false
|
||||
|
||||
Reference in New Issue
Block a user