1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { fetch } from "https://esm.town/v/std/fetch";
/**
* Create a new Qdrant collection in an existing cluster with the given name
* Uses recommended values for OpenAPI embeddings
*/
export async function createQdrantCollection(args: {
collectionName: string;
qdrantKey: string;
qdrantUrl: string;
}) {
const { collectionName, qdrantKey, qdrantUrl } = args;
const resp = await fetch(
`https://${qdrantUrl}/collections/${collectionName}`,
{
method: "PUT",
headers: {
"api-key": qdrantKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "facts",
vectors: { size: 1536, distance: "Cosine" },
}),
},
);
return resp.json();
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.