TS snippets

This commit is contained in:
Ivan Pleshkov
2025-12-09 15:06:49 +01:00
parent 7f2e456fad
commit 2eae9bd1df
4 changed files with 114 additions and 0 deletions
@@ -0,0 +1,29 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.query("{collection_name}", {
prefetch: {
query: {
text: "How to bake cookies?",
model: "openai/text-embedding-3-small",
options: {
"openai-api-key": "<YOUR_OPENAI_API_KEY>",
mrl: 64,
}
},
using: 'small',
limit: 1000,
},
query: {
text: "How to bake cookies?",
model: "openai/text-embedding-3-small",
options: {
"openai-api-key": "<YOUR_OPENAI_API_KEY>"
}
},
using: 'large',
limit: 10,
});
```
@@ -0,0 +1,27 @@
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.query("{collection_name}", {
prefetch: {
query: {
text: "How to bake cookies?",
model: "openai/text-embedding-3-small",
options: {
"openai-api-key": "<YOUR_OPENAI_API_KEY>",
mrl: 64,
}
},
using: 'small',
limit: 1000,
},
query: {
text: "How to bake cookies?",
model: "openai/text-embedding-3-small",
options: {
"openai-api-key": "<YOUR_OPENAI_API_KEY>"
}
},
using: 'large',
limit: 10,
});
@@ -0,0 +1,30 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.upsert("{collection_name}", {
points: [
{
id: 1,
vector: {
large: {
text: 'Recipe for baking chocolate chip cookies',
model: 'openai/text-embedding-3-small',
options: {
'openai-api-key': '<YOUR_OPENAI_API_KEY>',
},
},
small: {
text: 'Recipe for baking chocolate chip cookies',
model: 'openai/text-embedding-3-small',
options: {
'openai-api-key': '<YOUR_OPENAI_API_KEY>',
mrl: 64,
},
},
},
},
],
});
```
@@ -0,0 +1,28 @@
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.upsert("{collection_name}", {
points: [
{
id: 1,
vector: {
large: {
text: 'Recipe for baking chocolate chip cookies',
model: 'openai/text-embedding-3-small',
options: {
'openai-api-key': '<YOUR_OPENAI_API_KEY>',
},
},
small: {
text: 'Recipe for baking chocolate chip cookies',
model: 'openai/text-embedding-3-small',
options: {
'openai-api-key': '<YOUR_OPENAI_API_KEY>',
mrl: 64,
},
},
},
},
],
});