mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-09 03:23:09 -04:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 785d010cd3 | |||
| b878032131 | |||
| f7ec293a0f | |||
| 49a5e0a8cf | |||
| 118924799a | |||
| ec8f673dae |
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/doc
|
||||
|
||||
## 0.2.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f7ec293]
|
||||
- @llamaindex/workflow@1.1.11
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.2.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ Key build process:
|
||||
**Content Sources:**
|
||||
|
||||
- Local MDX files in `src/content/docs/`
|
||||
- External docs from `@llama-flow/docs` package
|
||||
- External docs from `@llamaindex/workflow-docs` package
|
||||
- Generated API docs from TypeScript source
|
||||
|
||||
### Development Notes
|
||||
|
||||
@@ -23,8 +23,8 @@ const config = {
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/docs/llamaflow/:path*.mdx",
|
||||
destination: "/docs/llamaflow/:path*",
|
||||
source: "/docs/workflows/:path*.mdx",
|
||||
destination: "/docs/workflows/:path*",
|
||||
permanent: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/doc",
|
||||
"version": "0.2.29",
|
||||
"version": "0.2.30",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "fumadocs-mdx",
|
||||
@@ -15,7 +15,7 @@
|
||||
"dependencies": {
|
||||
"@huggingface/transformers": "^3.5.0",
|
||||
"@icons-pack/react-simple-icons": "^10.1.0",
|
||||
"@llama-flow/docs": "0.0.8",
|
||||
"@llamaindex/workflow-docs": "0.1.1",
|
||||
"@llamaindex/chat-ui-docs": "^0.0.5",
|
||||
"@llamaindex/cloud": "workspace:*",
|
||||
"@llamaindex/core": "workspace:*",
|
||||
@@ -69,7 +69,7 @@
|
||||
"twoslash": "^0.3.1",
|
||||
"use-stick-to-bottom": "^1.0.42",
|
||||
"web-tree-sitter": "^0.24.4",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.67"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/env": "^15.3.0",
|
||||
|
||||
@@ -13,7 +13,7 @@ const INTERNAL_LINK_REGEX = /(?:(?:\]\(|\bhref=["'])\/docs\/([^")]+))/g;
|
||||
// This captures relative links like [text](./path) or 
|
||||
const RELATIVE_LINK_REGEX = /(?:\]\()(?:\s*)(?:\.\.?)\//g;
|
||||
|
||||
const ALLOWED_LINKS = ["/docs/llamaflow", "/docs/chat-ui"];
|
||||
const ALLOWED_LINKS = ["/docs/workflows", "/docs/chat-ui"];
|
||||
|
||||
interface LinkValidationResult {
|
||||
file: string;
|
||||
|
||||
@@ -11,9 +11,9 @@ import remarkMath from "remark-math";
|
||||
export const docs = defineDocs({
|
||||
dir: [
|
||||
"./src/content/docs",
|
||||
"./node_modules/@llama-flow/docs",
|
||||
"./node_modules/@llamaindex/workflow-docs",
|
||||
"./node_modules/@llamaindex/chat-ui-docs",
|
||||
// NOTE: When adding external docs (like chat-ui or llama-flow above),
|
||||
// NOTE: When adding external docs (like chat-ui or workflow-docs above),
|
||||
// make sure to also update:
|
||||
// 1. scripts/validate-links.mts - add to ALLOWED_LINKS array
|
||||
// 2. next.config.mjs - add redirect for .mdx files
|
||||
|
||||
@@ -9,10 +9,13 @@ Workflows are designed to be flexible and can be used to build agents, RAG flows
|
||||
To use workflows install this package:
|
||||
|
||||
```package-install
|
||||
npm i @llamaindex/workflow
|
||||
npm i @llamaindex/workflow-core
|
||||
```
|
||||
|
||||
This package is a stable, production-ready version of our [llama-flow](/docs/llamaflow) project.
|
||||
This contains the core functionality for the workflow system. You can read more about the core concepts in the [workflow-core](/docs/workflows) section.
|
||||
|
||||
While you can still reference the llama-flow documentation for detailed information about the underlying concepts, we recommend using the `@llamaindex/workflow` package for all new projects to ensure stability and long-term availability.
|
||||
In contrast, the `@llamaindex/workflow` package contains more utiltities, such as prebuilt agents.
|
||||
|
||||
```package-install
|
||||
npm i @llamaindex/workflow
|
||||
```
|
||||
|
||||
+31
-2
@@ -28,11 +28,12 @@ embedding vector(1536)
|
||||
);
|
||||
```
|
||||
|
||||
-- Create a function for similarity search
|
||||
-- Create a function for similarity search with filtering support
|
||||
```sql
|
||||
create function match_documents (
|
||||
query_embedding vector(1536),
|
||||
match_count int
|
||||
match_count int,
|
||||
filter jsonb DEFAULT '{}'
|
||||
) returns table (
|
||||
id uuid,
|
||||
content text,
|
||||
@@ -52,6 +53,7 @@ metadata,
|
||||
embedding,
|
||||
1 - (embedding <=> query_embedding) as similarity
|
||||
from documents
|
||||
where metadata @> filter
|
||||
order by embedding <=> query_embedding
|
||||
limit match_count;
|
||||
end;
|
||||
@@ -96,6 +98,7 @@ const index = await VectorStoreIndex.fromDocuments(documents, {
|
||||
```ts
|
||||
const queryEngine = index.asQueryEngine();
|
||||
|
||||
// Basic query without filters
|
||||
const response = await queryEngine.query({
|
||||
query: "What is in the document?",
|
||||
});
|
||||
@@ -104,6 +107,32 @@ const response = await queryEngine.query({
|
||||
console.log(response.toString());
|
||||
```
|
||||
|
||||
## Query with filters
|
||||
|
||||
You can filter documents based on metadata when querying:
|
||||
|
||||
```ts
|
||||
import { FilterOperator, MetadataFilters } from "llamaindex";
|
||||
|
||||
// Create a filter for documents with author = "Jane Smith"
|
||||
const filters: MetadataFilters = {
|
||||
filters: [
|
||||
{
|
||||
key: "author",
|
||||
value: "Jane Smith",
|
||||
operator: FilterOperator.EQ,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// Query with filters
|
||||
const filteredResponse = await vectorStore.query({
|
||||
queryEmbedding: embedModel.getQueryEmbedding("What is vector search?"),
|
||||
similarityTopK: 5,
|
||||
filters,
|
||||
});
|
||||
```
|
||||
|
||||
## Full code
|
||||
|
||||
```ts
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"pages": ["llamaindex", "api", "llamaflow", "chat-ui"]
|
||||
"pages": ["llamaindex", "api", "workflows", "chat-ui"]
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"tasks": {
|
||||
"build": {
|
||||
"inputs": [
|
||||
"node_modules/@llama-flow/docs/**",
|
||||
"node_modules/@llamaindex/workflow-docs/**",
|
||||
"node_modules/@llamaindex/chat-ui-docs/**",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/cloudflare-worker-agent-test
|
||||
|
||||
## 0.0.171
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.0.170
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/cloudflare-worker-agent-test",
|
||||
"version": "0.0.170",
|
||||
"version": "0.0.171",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/next-agent-test
|
||||
|
||||
## 0.1.171
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.1.170
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-agent-test",
|
||||
"version": "0.1.170",
|
||||
"version": "0.1.171",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# test-edge-runtime
|
||||
|
||||
## 0.1.170
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.1.169
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/nextjs-edge-runtime-test",
|
||||
"version": "0.1.169",
|
||||
"version": "0.1.170",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/next-node-runtime
|
||||
|
||||
## 0.1.39
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.1.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-node-runtime-test",
|
||||
"version": "0.1.38",
|
||||
"version": "0.1.39",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# vite-import-llamaindex
|
||||
|
||||
## 0.0.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.0.36
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-import-llamaindex",
|
||||
"private": true,
|
||||
"version": "0.0.36",
|
||||
"version": "0.0.37",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/waku-query-engine-test
|
||||
|
||||
## 0.0.171
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.0.170
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/waku-query-engine-test",
|
||||
"version": "0.0.170",
|
||||
"version": "0.0.171",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"dependencies": {
|
||||
"@llamaindex/workflow": "1.1.1",
|
||||
"llamaindex": "0.10.5",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.67"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsx": "^4.19.1",
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@
|
||||
"pg": "^8.12.0",
|
||||
"pgvector": "0.2.0",
|
||||
"tsx": "^4.19.3",
|
||||
"zod": "^3.24.2"
|
||||
"zod": "^3.25.67"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -68,7 +68,7 @@
|
||||
"mongodb": "6.7.0",
|
||||
"postgres": "^3.4.4",
|
||||
"wikipedia": "^2.1.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.67"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.9.0",
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
"start:discord": "node --import tsx ./src/discord.ts",
|
||||
"start:json": "node --import tsx ./src/json.ts",
|
||||
"start:obsidian": "node --import tsx ./src/obsidian.ts",
|
||||
"start:xml": "node --import tsx ./src/xml.ts"
|
||||
"start:xml": "node --import tsx ./src/xml.ts",
|
||||
"start:excel": "node --import tsx ./src/excel.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@llamaindex/cloud": "workspace:* || ^2.0.24",
|
||||
"@llamaindex/readers": "workspace:* || ^1.0.25",
|
||||
"@llamaindex/excel": "workspace:*",
|
||||
"llamaindex": "workspace:* || ^0.8.37"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { ExcelReader } from "@llamaindex/excel";
|
||||
|
||||
async function main() {
|
||||
// Load PDF
|
||||
const reader = new ExcelReader({
|
||||
sheetSpecifier: 0,
|
||||
concatRows: true,
|
||||
fieldSeparator: ",",
|
||||
keyValueSeparator: ":",
|
||||
});
|
||||
|
||||
const documents = await reader.loadData("../data/sample_excel_sheet.xls");
|
||||
|
||||
for (const doc of documents) {
|
||||
console.log(doc.text);
|
||||
console.log("----");
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/autotool
|
||||
|
||||
## 8.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 8.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/autotool-01-node-example
|
||||
|
||||
## 0.0.118
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
- @llamaindex/autotool@8.0.10
|
||||
|
||||
## 0.0.117
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
"scripts": {
|
||||
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
|
||||
},
|
||||
"version": "0.0.117"
|
||||
"version": "0.0.118"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
|
||||
"directory": "packages/autotool"
|
||||
},
|
||||
"version": "8.0.9",
|
||||
"version": "8.0.10",
|
||||
"description": "auto transpile your JS function to LLM Agent compatible",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -79,6 +79,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"p-retry": "^6.2.1",
|
||||
"zod": "^3.25.7"
|
||||
"zod": "^3.25.67"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"@types/node": "^22.9.0",
|
||||
"magic-bytes.js": "^1.10.0",
|
||||
"zod": "^3.23.8",
|
||||
"zod-to-json-schema": "^3.23.3"
|
||||
"zod": "^3.25.67",
|
||||
"zod-to-json-schema": "^3.24.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/experimental
|
||||
|
||||
## 0.0.187
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.0.186
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/experimental",
|
||||
"description": "Experimental package for LlamaIndexTS",
|
||||
"version": "0.0.186",
|
||||
"version": "0.0.187",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# llamaindex
|
||||
|
||||
## 0.11.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f7ec293]
|
||||
- @llamaindex/workflow@1.1.11
|
||||
|
||||
## 0.11.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "llamaindex",
|
||||
"version": "0.11.9",
|
||||
"version": "0.11.10",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# @llamaindex/excel
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 49a5e0a: feat: add Excel Reader
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@llamaindex/excel",
|
||||
"description": "Excel Reader for LlamaIndex",
|
||||
"version": "0.1.11",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
|
||||
"directory": "packages/providers/excel"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bunchee",
|
||||
"dev": "bunchee --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@llamaindex/core": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@llamaindex/core": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"xlsx": "^0.18.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./reader";
|
||||
@@ -0,0 +1,100 @@
|
||||
import { Document, FileReader } from "@llamaindex/core/schema";
|
||||
import * as XLSX from "xlsx";
|
||||
|
||||
interface ExcelReaderOptions {
|
||||
/** concatenate all rows into one document (default: true) */
|
||||
concatRows?: boolean;
|
||||
/** which sheet(s) to read; string name or zero-based index */
|
||||
sheetSpecifier?: string | number | undefined;
|
||||
/** what to put between each field (default: ", ") */
|
||||
fieldSeparator?: string;
|
||||
/** what to put between key and value (default: ":") */
|
||||
keyValueSeparator?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* ExcelReader reads an XLSX file from a Uint8Array (or Buffer) and
|
||||
* produces Document instances, either one per sheet (concatenated)
|
||||
* or one per row per sheet.
|
||||
*/
|
||||
export class ExcelReader extends FileReader<Document> {
|
||||
private concatRows: boolean;
|
||||
private sheetSpecifier?: string | number | undefined;
|
||||
private fieldSeparator: string;
|
||||
private keyValueSeparator: string;
|
||||
|
||||
/**
|
||||
* @param concatRows If true, all rows in a sheet become one Document;
|
||||
* otherwise one Document per row.
|
||||
* @param sheetSpecifier Name or zero-based index of the sheet to read;
|
||||
* undefined = all sheets.
|
||||
* @param fieldSeparator Separator between fields, e.g. ", ".
|
||||
* @param keyValueSeparator Separator between key & value, e.g. ": ".
|
||||
*/
|
||||
constructor({
|
||||
concatRows = true,
|
||||
sheetSpecifier = undefined,
|
||||
fieldSeparator = ", ",
|
||||
keyValueSeparator = ":",
|
||||
}: ExcelReaderOptions = {}) {
|
||||
super();
|
||||
this.concatRows = concatRows;
|
||||
this.sheetSpecifier = sheetSpecifier;
|
||||
this.fieldSeparator = fieldSeparator;
|
||||
this.keyValueSeparator = keyValueSeparator;
|
||||
}
|
||||
|
||||
async loadDataAsContent(content: Uint8Array): Promise<Document[]> {
|
||||
// Parse workbook from raw bytes
|
||||
const workbook = XLSX.read(content, { type: "array" });
|
||||
|
||||
// Choose which sheets to process
|
||||
let sheets = workbook.SheetNames;
|
||||
if (this.sheetSpecifier !== undefined) {
|
||||
if (typeof this.sheetSpecifier === "number") {
|
||||
const name = sheets[this.sheetSpecifier];
|
||||
sheets = name ? [name] : [];
|
||||
} else {
|
||||
sheets = sheets.includes(this.sheetSpecifier)
|
||||
? [this.sheetSpecifier]
|
||||
: [];
|
||||
}
|
||||
}
|
||||
|
||||
const docs: Document[] = [];
|
||||
|
||||
for (const name of sheets) {
|
||||
const ws = workbook.Sheets[name];
|
||||
|
||||
if (!ws) {
|
||||
continue; // Skip if worksheet is undefined
|
||||
}
|
||||
|
||||
// Convert sheet to JSON rows, using headers from first row
|
||||
const rows: Record<string, unknown>[] = XLSX.utils.sheet_to_json(ws, {
|
||||
defval: "N/A",
|
||||
});
|
||||
|
||||
const textLines: string[] = rows.map((r) =>
|
||||
Object.entries(r)
|
||||
.map(([h, v]) => `${h}${this.keyValueSeparator}${v}`)
|
||||
.join(this.fieldSeparator),
|
||||
);
|
||||
|
||||
if (this.concatRows) {
|
||||
docs.push(
|
||||
new Document({
|
||||
text: textLines.join("\n"),
|
||||
metadata: { sheetName: name },
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
textLines.forEach((text) =>
|
||||
docs.push(new Document({ text, metadata: { sheetName: name } })),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return docs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"outDir": "./lib",
|
||||
"tsBuildInfoFile": "./lib/.tsbuildinfo"
|
||||
},
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../core/tsconfig.json"
|
||||
},
|
||||
{
|
||||
"path": "../../env/tsconfig.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -40,8 +40,8 @@
|
||||
"peerDependencies": {
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"zod": "^3.24.2",
|
||||
"zod-to-json-schema": "^3.23.3"
|
||||
"zod": "^3.25.67",
|
||||
"zod-to-json-schema": "^3.24.6"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"zod": {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"devDependencies": {
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"zod": "^3.24.2"
|
||||
"zod": "^3.25.67"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@llamaindex/core": "workspace:*",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/supabase
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ec8f673: feat: support filter to supabase vector search
|
||||
|
||||
## 0.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/supabase",
|
||||
"description": "Supabase Storage for LlamaIndex",
|
||||
"version": "0.1.10",
|
||||
"version": "0.1.11",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
BaseVectorStore,
|
||||
metadataDictToNode,
|
||||
nodeToMetadata,
|
||||
type MetadataFilters,
|
||||
type VectorStoreBaseParams,
|
||||
type VectorStoreQuery,
|
||||
type VectorStoreQueryResult,
|
||||
@@ -18,6 +19,9 @@ export interface SupabaseVectorStoreInit extends VectorStoreBaseParams {
|
||||
table: string;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type SupabaseFilter = Record<string, any>;
|
||||
|
||||
interface SearchEmbeddingsResponse {
|
||||
id: string;
|
||||
content: string;
|
||||
@@ -137,6 +141,7 @@ export class SupabaseVectorStore extends BaseVectorStore {
|
||||
const { data, error } = await this.supabaseClient.rpc("match_documents", {
|
||||
query_embedding: query.queryEmbedding,
|
||||
match_count: query.similarityTopK,
|
||||
filter: this.toSupabaseFilter(query.filters),
|
||||
});
|
||||
|
||||
if (error) {
|
||||
@@ -176,4 +181,20 @@ export class SupabaseVectorStore extends BaseVectorStore {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts metadata filters to supabase query filter format
|
||||
* @param queryFilters - Metadata filters to convert
|
||||
* @returns supabase query filter object
|
||||
* @private
|
||||
*/
|
||||
private toSupabaseFilter(queryFilters: MetadataFilters | undefined) {
|
||||
if (queryFilters?.filters && queryFilters.filters.length > 0) {
|
||||
return queryFilters.filters.reduce<SupabaseFilter>((acc, curr) => {
|
||||
acc[curr.key] = curr.value;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
import { Settings } from "@llamaindex/core/global";
|
||||
import { Document } from "@llamaindex/core/schema";
|
||||
import {
|
||||
FilterOperator,
|
||||
MetadataFilters,
|
||||
VectorStoreQueryMode,
|
||||
} from "@llamaindex/core/vector-store";
|
||||
import { OpenAIEmbedding } from "@llamaindex/openai";
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import {
|
||||
afterEach,
|
||||
beforeAll,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
vi,
|
||||
} from "vitest";
|
||||
import { SupabaseVectorStore } from "../src";
|
||||
|
||||
async function isSupabaseAvailable(): Promise<boolean> {
|
||||
if (!process.env.SUPABASE_URL || !process.env.SUPABASE_KEY) {
|
||||
return false;
|
||||
@@ -45,4 +60,88 @@ describe("SupabaseVectorStore", async () => {
|
||||
expect(vectorStore).toBeDefined();
|
||||
expect(vectorStore).toBeInstanceOf(SupabaseVectorStore);
|
||||
});
|
||||
|
||||
describe("query", () => {
|
||||
let supabase: ReturnType<typeof createClient>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let rpcSpy: any;
|
||||
let vectorStore: SupabaseVectorStore;
|
||||
let mockEmbedding: number[];
|
||||
|
||||
beforeEach(() => {
|
||||
supabase = createClient(
|
||||
process.env.SUPABASE_URL!,
|
||||
process.env.SUPABASE_KEY!,
|
||||
);
|
||||
|
||||
rpcSpy = vi.spyOn(supabase, "rpc").mockImplementation(() => {
|
||||
return {
|
||||
data: [],
|
||||
error: null,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any;
|
||||
});
|
||||
|
||||
vectorStore = new SupabaseVectorStore({
|
||||
client: supabase,
|
||||
table: "test",
|
||||
});
|
||||
|
||||
mockEmbedding = new Array(1536).fill(0.1);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
rpcSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("should query without filters", async () => {
|
||||
const doc = new Document({
|
||||
text: "Test document",
|
||||
});
|
||||
doc.embedding = mockEmbedding;
|
||||
|
||||
await vectorStore.query({
|
||||
queryEmbedding: doc.embedding!,
|
||||
similarityTopK: 5,
|
||||
mode: VectorStoreQueryMode.DEFAULT,
|
||||
});
|
||||
|
||||
expect(rpcSpy).toHaveBeenCalledWith("match_documents", {
|
||||
query_embedding: doc.embedding,
|
||||
match_count: 5,
|
||||
filter: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("should pass filters to the match_documents RPC call", async () => {
|
||||
const doc = new Document({
|
||||
text: "Test document",
|
||||
metadata: { category: "test" },
|
||||
});
|
||||
doc.embedding = mockEmbedding;
|
||||
|
||||
const filters: MetadataFilters = {
|
||||
filters: [
|
||||
{
|
||||
key: "category",
|
||||
value: "test",
|
||||
operator: FilterOperator.EQ,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
await vectorStore.query({
|
||||
queryEmbedding: doc.embedding!,
|
||||
similarityTopK: 5,
|
||||
filters,
|
||||
mode: VectorStoreQueryMode.DEFAULT,
|
||||
});
|
||||
|
||||
expect(rpcSpy).toHaveBeenCalledWith("match_documents", {
|
||||
query_embedding: doc.embedding,
|
||||
match_count: 5,
|
||||
filter: { category: "test" },
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"@llamaindex/core": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.67"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@llamaindex/core": "workspace:*",
|
||||
|
||||
@@ -54,6 +54,6 @@
|
||||
"marked": "^14.1.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"wikipedia": "^2.1.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.67"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/workflow
|
||||
|
||||
## 1.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f7ec293: Update workflow-core
|
||||
|
||||
## 1.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/workflow",
|
||||
"description": "Workflow API",
|
||||
"version": "1.1.10",
|
||||
"version": "1.1.11",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
@@ -45,10 +45,10 @@
|
||||
"peerDependencies": {
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"zod": "^3.23.8",
|
||||
"zod-to-json-schema": "^3.23.3"
|
||||
"zod": "^3.25.67",
|
||||
"zod-to-json-schema": "^3.24.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@llama-flow/core": "^0.4.4"
|
||||
"@llamaindex/workflow-core": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getContext, type WorkflowEventData } from "@llama-flow/core";
|
||||
import { getContext, type WorkflowEventData } from "@llamaindex/workflow-core";
|
||||
import {
|
||||
AgentWorkflow,
|
||||
startAgentEvent,
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { Settings } from "@llamaindex/core/global";
|
||||
import type { ChatMessage, MessageContent } from "@llamaindex/core/llms";
|
||||
import { ChatMemoryBuffer } from "@llamaindex/core/memory";
|
||||
import { PromptTemplate } from "@llamaindex/core/prompts";
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { stringifyJSONToMessageContent } from "@llamaindex/core/utils";
|
||||
import {
|
||||
createWorkflow,
|
||||
getContext,
|
||||
@@ -7,14 +13,8 @@ import {
|
||||
type WorkflowContext,
|
||||
type WorkflowEvent,
|
||||
type WorkflowEventData,
|
||||
} from "@llama-flow/core";
|
||||
import { createStatefulMiddleware } from "@llama-flow/core/middleware/state";
|
||||
import { Settings } from "@llamaindex/core/global";
|
||||
import type { ChatMessage, MessageContent } from "@llamaindex/core/llms";
|
||||
import { ChatMemoryBuffer } from "@llamaindex/core/memory";
|
||||
import { PromptTemplate } from "@llamaindex/core/prompts";
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { stringifyJSONToMessageContent } from "@llamaindex/core/utils";
|
||||
} from "@llamaindex/workflow-core";
|
||||
import { createStatefulMiddleware } from "@llamaindex/workflow-core/middleware/state";
|
||||
import { z } from "zod";
|
||||
import type { AgentWorkflowState, BaseWorkflowAgent } from "./base";
|
||||
import {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { WorkflowContext } from "@llama-flow/core";
|
||||
import type { BaseToolWithCall, ChatMessage, LLM } from "@llamaindex/core/llms";
|
||||
import { BaseMemory } from "@llamaindex/core/memory";
|
||||
import type { WorkflowContext } from "@llamaindex/workflow-core";
|
||||
import type { AgentOutput, AgentToolCallResult } from "./events";
|
||||
|
||||
export type AgentWorkflowState = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { workflowEvent } from "@llama-flow/core";
|
||||
import type { JSONValue } from "@llamaindex/core/global";
|
||||
import type { ChatMessage, ToolResult } from "@llamaindex/core/llms";
|
||||
import { workflowEvent } from "@llamaindex/workflow-core";
|
||||
|
||||
export type AgentToolCall = {
|
||||
agentName: string;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { type WorkflowContext, type WorkflowEvent } from "@llama-flow/core";
|
||||
import type { JSONObject } from "@llamaindex/core/global";
|
||||
import { Settings } from "@llamaindex/core/global";
|
||||
import {
|
||||
@@ -8,6 +7,10 @@ import {
|
||||
type ChatResponseChunk,
|
||||
} from "@llamaindex/core/llms";
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import {
|
||||
type WorkflowContext,
|
||||
type WorkflowEvent,
|
||||
} from "@llamaindex/workflow-core";
|
||||
import { z } from "zod";
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
import { AgentWorkflow } from "./agent-workflow";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export * from "@llama-flow/core";
|
||||
export * from "@llama-flow/core/middleware/snapshot";
|
||||
export * from "@llama-flow/core/middleware/state";
|
||||
export * from "@llama-flow/core/stream/run";
|
||||
export { zodEvent } from "@llama-flow/core/util/zod";
|
||||
export * from "@llamaindex/workflow-core";
|
||||
export * from "@llamaindex/workflow-core/middleware/snapshot";
|
||||
export * from "@llamaindex/workflow-core/middleware/state";
|
||||
export * from "@llamaindex/workflow-core/stream/run";
|
||||
export { zodEvent } from "@llamaindex/workflow-core/util/zod";
|
||||
export * from "./agent/index.js";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { type WorkflowContext } from "@llama-flow/core";
|
||||
import { zodEvent } from "@llama-flow/core/util/zod";
|
||||
import { ChatMessage } from "@llamaindex/core/llms";
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { MockLLM } from "@llamaindex/core/utils";
|
||||
import { type WorkflowContext } from "@llamaindex/workflow-core";
|
||||
import { zodEvent } from "@llamaindex/workflow-core/util/zod";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { z } from "zod";
|
||||
import { AgentToolCallResult, FunctionAgent } from "../src/agent";
|
||||
|
||||
Generated
+264
-226
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,6 @@
|
||||
"llamaindex": "workspace:*",
|
||||
"@llamaindex/workflow": "workspace:*",
|
||||
"@llamaindex/openai": "workspace:*",
|
||||
"zod": "^3.24.2"
|
||||
"zod": "^3.25.67"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@
|
||||
{
|
||||
"path": "./packages/providers/xai/tsconfig.json"
|
||||
},
|
||||
{
|
||||
"path": "./packages/providers/excel/tsconfig.json"
|
||||
},
|
||||
{
|
||||
"path": "./packages/cloud/tsconfig.json"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/unit-test
|
||||
|
||||
## 0.1.39
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f7ec293]
|
||||
- @llamaindex/workflow@1.1.11
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.1.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/unit-test",
|
||||
"private": true,
|
||||
"version": "0.1.38",
|
||||
"version": "0.1.39",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
@@ -27,6 +27,6 @@
|
||||
"tree-sitter": "^0.22.1",
|
||||
"tree-sitter-javascript": "^0.23.1",
|
||||
"tree-sitter-typescript": "^0.23.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.67"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user