mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-30 16:38:31 +02:00
docs: Query API snippets with Python (#1095)
Co-authored-by: generall <andrey@vasnetsov.com>
This commit is contained in:
@@ -43,11 +43,15 @@ from qdrant_client import QdrantClient, models
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
|
||||
client.recommend(
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
positive=[100, 231],
|
||||
negative=[718, [0.2, 0.3, 0.4, 0.5]],
|
||||
strategy=models.RecommendStrategy.AVERAGE_VECTOR,
|
||||
query=models.RecommendQuery(
|
||||
recommend=models.RecommendInput(
|
||||
positive=[100, 231],
|
||||
negative=[718, [0.2, 0.3, 0.4, 0.5]],
|
||||
strategy=models.RecommendStrategy.AVERAGE_VECTOR,
|
||||
)
|
||||
),
|
||||
query_filter=models.Filter(
|
||||
must=[
|
||||
models.FieldCondition(
|
||||
@@ -245,10 +249,14 @@ POST /collections/{collection_name}/points/query
|
||||
```
|
||||
|
||||
```python
|
||||
client.recommend(
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
positive=[100, 231],
|
||||
negative=[718],
|
||||
query=models.RecommendQuery(
|
||||
recommend=models.RecommendInput(
|
||||
positive=[100, 231],
|
||||
negative=[718],
|
||||
)
|
||||
),
|
||||
using="image",
|
||||
limit=10,
|
||||
)
|
||||
@@ -350,15 +358,18 @@ POST /collections/{collection_name}/points/query
|
||||
```
|
||||
|
||||
```python
|
||||
client.recommend(
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
positive=[100, 231],
|
||||
negative=[718],
|
||||
query=models.RecommendQuery(
|
||||
recommend=models.RecommendInput(
|
||||
positive=[100, 231],
|
||||
negative=[718],
|
||||
)
|
||||
),
|
||||
using="image",
|
||||
limit=10,
|
||||
lookup_from=models.LookupLocation(
|
||||
collection="{external_collection_name}",
|
||||
vector="{external_vector_name}"
|
||||
collection="{external_collection_name}", vector="{external_vector_name}"
|
||||
),
|
||||
)
|
||||
```
|
||||
@@ -520,13 +531,25 @@ filter_ = models.Filter(
|
||||
)
|
||||
|
||||
recommend_queries = [
|
||||
models.RecommendRequest(
|
||||
positive=[100, 231], negative=[718], filter=filter_, limit=3
|
||||
models.QueryRequest(
|
||||
query=models.RecommendQuery(
|
||||
recommend=models.RecommendInput(positive=[100, 231], negative=[718])
|
||||
),
|
||||
filter=filter_,
|
||||
limit=3,
|
||||
),
|
||||
models.QueryRequest(
|
||||
query=models.RecommendQuery(
|
||||
recommend=models.RecommendInput(positive=[200, 67], negative=[300])
|
||||
),
|
||||
filter=filter_,
|
||||
limit=3,
|
||||
),
|
||||
models.RecommendRequest(positive=[200, 67], negative=[300], filter=filter_, limit=3),
|
||||
]
|
||||
|
||||
client.recommend_batch(collection_name="{collection_name}", requests=recommend_queries)
|
||||
client.query_batch_points(
|
||||
collection_name="{collection_name}", requests=recommend_queries
|
||||
)
|
||||
```
|
||||
|
||||
```typescript
|
||||
@@ -776,18 +799,22 @@ from qdrant_client import QdrantClient, models
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
|
||||
discover_queries = [
|
||||
models.DiscoverRequest(
|
||||
target=[0.2, 0.1, 0.9, 0.7],
|
||||
context=[
|
||||
models.ContextExamplePair(
|
||||
positive=100,
|
||||
negative=718,
|
||||
),
|
||||
models.ContextExamplePair(
|
||||
positive=200,
|
||||
negative=300,
|
||||
),
|
||||
],
|
||||
models.QueryRequest(
|
||||
query=models.DiscoverQuery(
|
||||
discover=models.DiscoverInput(
|
||||
target=[0.2, 0.1, 0.9, 0.7],
|
||||
context=[
|
||||
models.ContextPair(
|
||||
positive=100,
|
||||
negative=718,
|
||||
),
|
||||
models.ContextPair(
|
||||
positive=200,
|
||||
negative=300,
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
limit=10,
|
||||
),
|
||||
]
|
||||
@@ -948,17 +975,19 @@ from qdrant_client import QdrantClient, models
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
|
||||
discover_queries = [
|
||||
models.DiscoverRequest(
|
||||
context=[
|
||||
models.ContextExamplePair(
|
||||
positive=100,
|
||||
negative=718,
|
||||
),
|
||||
models.ContextExamplePair(
|
||||
positive=200,
|
||||
negative=300,
|
||||
),
|
||||
],
|
||||
models.QueryRequest(
|
||||
query=models.ContextQuery(
|
||||
context=[
|
||||
models.ContextPair(
|
||||
positive=100,
|
||||
negative=718,
|
||||
),
|
||||
models.ContextPair(
|
||||
positive=200,
|
||||
negative=300,
|
||||
),
|
||||
],
|
||||
),
|
||||
limit=10,
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user