Fix type-checking errors in snippets (code only, no .md)

This commit both:
- Fixes pre-existing mistakes in snippets, aka wrong code samples.
- Adds hidden (`@hide`) statements that do not appear in the docs,
  but satisfy typecheckers.
This commit is contained in:
xzfc
2025-11-28 22:02:07 +00:00
parent 00896acb28
commit 74a785218b
410 changed files with 1161 additions and 252 deletions
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -1,6 +1,8 @@
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.upsert_points(
UpsertPointsBuilder::new(
@@ -5,6 +5,7 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.UpsertAsync(
collectionName: "{collection_name}",
points: new List<PointStruct>
@@ -14,12 +15,8 @@ public class Snippet
Id = 1,
Vectors = new Dictionary<string, Vector>
{
["image"] = new() {
Data = {0.9f, 0.1f, 0.1f, 0.2f}
},
["text"] = new() {
Data = {0.4f, 0.7f, 0.1f, 0.8f, 0.1f}
},
["image"] = new float[] {0.9f, 0.1f, 0.1f, 0.2f},
["text"] = new float[] {0.4f, 0.7f, 0.1f, 0.8f, 0.1f},
["text-sparse"] = ([0.1f, 0.2f, 0.3f, 0.4f], [1, 3, 5, 7]),
}
}
@@ -7,6 +7,14 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) }
// @hide-end
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -10,6 +10,11 @@ import java.util.Map;
public class Snippet {
public static void run() throws Exception {
// @hide-start
io.qdrant.client.QdrantClient client =
new io.qdrant.client.QdrantClient(io.qdrant.client.QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client
.upsertAsync(
"{collection_name}",
@@ -1,3 +1,4 @@
# mypy: disable-error-code="dict-item"
from qdrant_client import QdrantClient, models # @hide
client = QdrantClient(url="http://localhost:6333") # @hide
@@ -4,6 +4,8 @@ use qdrant_client::qdrant::{
use qdrant_client::Payload;
pub async fn main() -> anyhow::Result<()> {
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.upsert_points(
UpsertPointsBuilder::new(
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -11,6 +11,11 @@ import java.util.Map;
public class Snippet {
public static void run() throws Exception {
// @hide-start
io.qdrant.client.QdrantClient client =
new io.qdrant.client.QdrantClient(io.qdrant.client.QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client
.upsertAsync(
"{collection_name}",
@@ -1,9 +1,11 @@
use std::collections::HashMap;
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder, Vector};
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use qdrant_client::Payload;
pub async fn main() -> anyhow::Result<()> {
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.upsert_points(
UpsertPointsBuilder::new(
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -21,7 +21,7 @@ public class Snippet {
.upsertAsync(
UpsertPoints.newBuilder()
.setCollectionName("{collectionName}")
.addPoint(
.addPoints(
PointStruct.newBuilder()
.setId(id(1))
.setVectors(vectors(0.05f, 0.61f, 0.76f, 0.74f))
@@ -14,7 +14,7 @@ client.upsert("{collection_name}", {
},
}
],
updateFilter: {
update_filter: {
must: [
{
key: "version",
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -2,6 +2,8 @@ use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use qdrant_client::Payload;
pub async fn main() -> anyhow::Result<()> {
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.upsert_points(
UpsertPointsBuilder::new(
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -10,6 +10,11 @@ import java.util.Map;
public class Snippet {
public static void run() throws Exception {
// @hide-start
io.qdrant.client.QdrantClient client =
new io.qdrant.client.QdrantClient(io.qdrant.client.QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client
.upsertAsync(
"{collection_name}",
@@ -30,9 +35,9 @@ public class Snippet {
namedVectors(
Map.of(
"image",
List.of(0.2f, 0.1f, 0.3f, 0.9f),
vector(List.of(0.2f, 0.1f, 0.3f, 0.9f)),
"text",
List.of(0.5f, 0.2f, 0.7f, 0.4f, 0.7f, 0.2f, 0.3f, 0.9f))))
vector(List.of(0.5f, 0.2f, 0.7f, 0.4f, 0.7f, 0.2f, 0.3f, 0.9f)))))
.build()))
.get();
}
@@ -4,6 +4,8 @@ use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use qdrant_client::Payload;
pub async fn main() -> anyhow::Result<()> {
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.upsert_points(
UpsertPointsBuilder::new(
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -1,5 +1,5 @@
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder, Vector};
use qdrant_client::Qdrant;
use qdrant_client::{Payload, Qdrant};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -7,9 +7,9 @@ client.upsert("{collection_name}", {
{
id: 1,
vector: [
[-0.013, 0.020, -0.007, -0.111, ...],
[-0.030, -0.055, 0.001, 0.072, ...],
[-0.041, 0.014, -0.032, -0.062, ...]
[-0.013, 0.020, -0.007, -0.111],
[-0.030, -0.055, 0.001, 0.072],
[-0.041, 0.014, -0.032, -0.062]
],
}
]
@@ -30,10 +30,7 @@ public class Snippet
Payload =
{
["city"] = new[] { "Berlin", "Moscow" },
["price"] = new Value
{
ListValue = new ListValue { Values = { new Value[] { 1.99, 2.99 } } }
}
["price"] = new Value[] { 1.99, 2.99 }
}
}
}
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -1,6 +1,7 @@
package com.example.snippets_amalgamation;
import static io.qdrant.client.PointIdFactory.id;
import static io.qdrant.client.ValueFactory.list;
import static io.qdrant.client.ValueFactory.value;
import static io.qdrant.client.VectorsFactory.vectors;
@@ -1,5 +1,5 @@
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use qdrant_client::{Payload, Qdrant, QdrantError};
use qdrant_client::{Payload, Qdrant};
use serde_json::json;
pub async fn main() -> anyhow::Result<()> {
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -19,7 +21,7 @@ func Main() {
Id: qdrant.NewIDNum(1),
Vectors: qdrant.NewVectors(0.9, 0.1, 0.1),
Payload: qdrant.NewValueMap(map[string]any{"group_id": "user_1"}),
}
},
},
ShardKeySelector: &qdrant.ShardKeySelector{
ShardKeys: []*qdrant.ShardKey{
@@ -1,11 +1,15 @@
package com.example.snippets_amalgamation;
import static io.qdrant.client.PointIdFactory.id;
import static io.qdrant.client.ShardKeyFactory.shardKey;
import static io.qdrant.client.ValueFactory.value;
import static io.qdrant.client.VectorsFactory.vectors;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.PointStruct;
import io.qdrant.client.grpc.Points.ShardKeySelector;
import io.qdrant.client.grpc.Points.UpsertPoints;
import java.util.List;
import java.util.Map;
@@ -1,5 +1,5 @@
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{PointStruct, ShardKeySelectorBuilder, UpsertPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -1,5 +1,9 @@
package com.example.snippets_amalgamation;
import static io.qdrant.client.PointIdFactory.id;
import static io.qdrant.client.ValueFactory.value;
import static io.qdrant.client.VectorsFactory.vectors;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.PointStruct;