@xano-sdk/vector 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +68 -0
- package/LICENSE +21 -0
- package/README.md +210 -0
- package/dist/index.d.ts +1189 -0
- package/dist/index.js +1429 -0
- package/llms.txt +62 -0
- package/package.json +85 -0
package/llms.txt
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @xano-sdk/vector
|
|
2
|
+
|
|
3
|
+
> Vector embedding, multimodal document ingestion, chunking, and similarity search module for Xano SDK, using Google Gemini Embeddings 2 (768 dimensions) and pgvector. Every export is a typed Xano SDK def; nothing runs inside the package. Peer: `@xano/sdk` `>=1.0.0 <2.0.0`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
`xanosdk marketplace install @xano-sdk/vector` (installs and wires it into `xano/index.ts`), or `npm install @xano-sdk/vector @xano/sdk`.
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { workspace, workspaceConfig } from "@xano/sdk";
|
|
13
|
+
import { registerVector } from "@xano-sdk/vector";
|
|
14
|
+
|
|
15
|
+
const ws = workspace("my-app").registerWorkspace(
|
|
16
|
+
workspaceConfig({ name: "my-app", env: { GEMINI_API_KEY: "" } }),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const vector = registerVector(ws, { defaultStrategy: "markdown" });
|
|
20
|
+
|
|
21
|
+
export default vector.xano;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Put the key's value in `xano/.env` (`GEMINI_API_KEY=...`). Never pass `process.env.X` into `workspaceConfig({ env })`: it is baked into the bundle at export.
|
|
25
|
+
|
|
26
|
+
## Exports
|
|
27
|
+
|
|
28
|
+
- `registerVector(xano, opts?: VectorOptions): RegisteredVector` — builds every def and registers it on the workspace. Call once per workspace; a second call throws.
|
|
29
|
+
- `createVector(opts?: VectorOptions): Vector` — builds the same defs without registering: `document`, `chunk`, `embedFn`, `chunkFn`, `ingestFn`, `searchFn`, `searchTool`, `group`, `documents`, `search`, `queries`, `options`.
|
|
30
|
+
- Def factories: `documentTable`, `chunkTable`, `generateEmbeddingFn`, `chunkTextFn`, `ingestDocumentFn`, `searchVectorsFn`, `vectorSearchTool`, `vectorGroup`, `documentQueries`, `searchQueries`.
|
|
31
|
+
- `resolveOptions`, `DEFAULT_NAMES`, `CHUNK_STRATEGIES` (`fixed`, `paragraph`, `sentence`, `markdown`, `custom`), `DOCUMENT_STATUSES`, `GEMINI_EMBEDDING_DIMENSIONS` (768), and `DEFAULT_*` constants.
|
|
32
|
+
- Types for every endpoint's input and response (`SearchInput`, `SearchResponse`, `VectorEndpoints`, …).
|
|
33
|
+
|
|
34
|
+
## Options (`VectorOptions`)
|
|
35
|
+
|
|
36
|
+
- `apiKeyEnv` (`"GEMINI_API_KEY"`), `model` (`"gemini-embedding-2"`), `taskTypeDocument` (`"RETRIEVAL_DOCUMENT"`), `taskTypeQuery` (`"RETRIEVAL_QUERY"`).
|
|
37
|
+
- `defaultStrategy` (`"paragraph"`), `defaultChunkSize` (500, 20–10000), `defaultChunkOverlap` (50, `< defaultChunkSize`).
|
|
38
|
+
- `searchLimit` (10, 1–100), `searchThreshold` (0.0, 0–1), `citationFormat` (`"markdown" | "numeric" | "none"`, default `"markdown"`).
|
|
39
|
+
- `authTable`, `authenticated` (defaults to `true` when `authTable` is set), `userIdType` (`"int" | "uuid"`, inferred from `authTable`).
|
|
40
|
+
- `routePrefix` (`"vector"`), `canonical` (API group canonical; also replaces `routePrefix` and prefixes def names), `names` (per-def name overrides), `tags`.
|
|
41
|
+
|
|
42
|
+
With `authenticated`, every endpoint requires sign-in and document endpoints only see the caller's documents. Search is not scoped per user: it spans all indexed chunks.
|
|
43
|
+
|
|
44
|
+
## Endpoints
|
|
45
|
+
|
|
46
|
+
Base: `/api:<canonical>/<routePrefix>`. Without `canonical`, Xano assigns the group canonical on deploy.
|
|
47
|
+
|
|
48
|
+
- `POST /documents/create` — `{ title, content?, media_data?, mime_type?, metadata?, strategy?, chunk_size?, chunk_overlap? }` → `{ document, chunk_count, status }`.
|
|
49
|
+
- `GET /documents` — `{ page?, per_page? }` → paged `{ items, curPage, perPage, itemsReceived, itemsTotal, pageTotal }`.
|
|
50
|
+
- `GET /documents/{id}` — → `{ document, chunks }`.
|
|
51
|
+
- `DELETE /documents/{id}/delete` — deletes the document and its chunks → `{ deleted, id }`.
|
|
52
|
+
- `POST /documents/{id}/reindex` — `{ strategy?, chunk_size?, chunk_overlap? }` → `{ document_id, status, chunk_count }`.
|
|
53
|
+
- `POST /search` — `{ query?, query_media_data?, query_mime_type?, query_embedding?, limit?, threshold? }` → `{ results, count }`.
|
|
54
|
+
- `POST /embed` — `{ text?, media_data?, mime_type?, model? }` → `{ embedding, dimensions }`.
|
|
55
|
+
|
|
56
|
+
## Agent tool
|
|
57
|
+
|
|
58
|
+
`vector.searchTool` (name `vector_search`) goes in `agent({ tools: [vector.searchTool] })` or an `mcpServer`'s `tools`. Inputs: `query`, `media_data?`, `mime_type?`, `limit` (5). An `agent()` needs `llm: { type, model?, apiKey?, systemPrompt? }`; it has no top-level `instructions`.
|
|
59
|
+
|
|
60
|
+
## Multimodal
|
|
61
|
+
|
|
62
|
+
Model `gemini-embedding-2` at 768 dimensions (MRL). Text, Markdown, `image/png`, `image/jpeg`, `image/webp`, `audio/mp3`, `audio/wav`, `video/mp4`. `media_data` is base64.
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xano-sdk/vector",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Plug-and-play vector search & multimodal Gemini embedding pipeline (document/chunk tables, ingestion, chunking strategies, management APIs, and agent tool) as typed Xano SDK defs.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"author": "Xano",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"xano",
|
|
13
|
+
"xanosdk",
|
|
14
|
+
"xanoscript",
|
|
15
|
+
"vector",
|
|
16
|
+
"embeddings",
|
|
17
|
+
"gemini",
|
|
18
|
+
"rag",
|
|
19
|
+
"search",
|
|
20
|
+
"ai",
|
|
21
|
+
"agent",
|
|
22
|
+
"pgvector",
|
|
23
|
+
"backend",
|
|
24
|
+
"codegen"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/xanots/vector.git"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/xanots/vector#readme",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/xanots/vector/issues"
|
|
33
|
+
},
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"xanosdk": {
|
|
36
|
+
"register": "registerVector",
|
|
37
|
+
"returns": "handle",
|
|
38
|
+
"options": {}
|
|
39
|
+
},
|
|
40
|
+
"main": "./dist/index.js",
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"import": "./dist/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./package.json": "./package.json"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"!dist/**/*.map",
|
|
52
|
+
"README.md",
|
|
53
|
+
"AGENTS.md",
|
|
54
|
+
"llms.txt"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "tsc --noEmit && vitest run",
|
|
60
|
+
"test:watch": "vitest",
|
|
61
|
+
"lint": "eslint .",
|
|
62
|
+
"fixture:regen": "tsx scripts/regen-golden.ts",
|
|
63
|
+
"prepublishOnly": "npm run build",
|
|
64
|
+
"release": "npm publish --access public",
|
|
65
|
+
"release:beta": "npm version prerelease --preid=beta -m \"chore(release): %s\" && npm publish --tag beta --access public"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=20"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"@xano/sdk": ">=1.0.0 <2.0.0"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@eslint/js": "^9.0.0",
|
|
75
|
+
"@types/node": "^20.0.0",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
77
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
78
|
+
"@xano/sdk": "1.0.0",
|
|
79
|
+
"eslint": "^9.0.0",
|
|
80
|
+
"tsup": "^8.0.0",
|
|
81
|
+
"tsx": "^4.23.1",
|
|
82
|
+
"typescript": "^5.5.0",
|
|
83
|
+
"vitest": "^2.0.0"
|
|
84
|
+
}
|
|
85
|
+
}
|