mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-01 22:14:03 -04:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 785d010cd3 | |||
| b878032131 | |||
| f7ec293a0f | |||
| 49a5e0a8cf | |||
| 118924799a | |||
| ec8f673dae | |||
| 85039a5360 | |||
| d7305edb53 | |||
| 096bf2bda1 | |||
| c5846bd7dc |
@@ -1,5 +1,20 @@
|
||||
# @llamaindex/doc
|
||||
|
||||
## 0.2.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f7ec293]
|
||||
- @llamaindex/workflow@1.1.11
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.2.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c5846bd]
|
||||
- @llamaindex/readers@3.1.10
|
||||
|
||||
## 0.2.28
|
||||
|
||||
### 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.28",
|
||||
"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
|
||||
|
||||
@@ -74,12 +74,21 @@ const server = mcp({
|
||||
args: ["-y", "@modelcontextprotocol/server-filesystem", "."],
|
||||
verbose: true,
|
||||
});
|
||||
// or by SSE
|
||||
// or by StreamableHTTP transport
|
||||
const server = mcp({
|
||||
url: "http://localhost:8000/mcp",
|
||||
verbose: true,
|
||||
});
|
||||
|
||||
// if your MCP server is not using StreamableHTTP transport, you can also use SSE transport
|
||||
// by setting useSSETransport to true.
|
||||
// See: https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse-deprecated
|
||||
const server = mcp({
|
||||
url: "http://localhost:8000/mcp",
|
||||
useSSETransport: true,
|
||||
verbose: true,
|
||||
});
|
||||
|
||||
// 3. Get tools from MCP server
|
||||
const tools = await server.tools();
|
||||
|
||||
|
||||
@@ -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,18 @@
|
||||
# @llamaindex/next-node-runtime
|
||||
|
||||
## 0.1.39
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.10
|
||||
|
||||
## 0.1.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c5846bd]
|
||||
- @llamaindex/readers@3.1.10
|
||||
|
||||
## 0.1.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-node-runtime-test",
|
||||
"version": "0.1.37",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# examples
|
||||
|
||||
## 0.3.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [096bf2b]
|
||||
- Updated dependencies [c5846bd]
|
||||
- @llamaindex/tools@0.1.0
|
||||
- @llamaindex/readers@3.1.10
|
||||
|
||||
## 0.3.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -6,15 +6,24 @@ async function main() {
|
||||
// Create an MCP server for filesystem tools
|
||||
const server = mcp({
|
||||
command: "npx",
|
||||
args: ["-y", "@modelcontextprotocol/server-filesystem", "."],
|
||||
args: ["-y", "@modelcontextprotocol/server-filesystem@latest", "."],
|
||||
verbose: true,
|
||||
});
|
||||
// You can also connect to the MCP server using SSE
|
||||
// See: https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse
|
||||
//
|
||||
// You can also connect to a remote MCP server using:
|
||||
// 1. StreamableHTTP transport (recommended)
|
||||
// See: https://modelcontextprotocol.io/docs/concepts/transports#streamable-http
|
||||
// const server = mcp({
|
||||
// url: "http://localhost:8000/mcp",
|
||||
// verbose: true,
|
||||
// });
|
||||
// 2.Or using SSE transport (will be deprecated soon)
|
||||
// See: https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse-deprecated
|
||||
// const server = mcp({
|
||||
// url: "http://localhost:8000/mcp",
|
||||
// useSSETransport: true,
|
||||
// verbose: true,
|
||||
// });
|
||||
|
||||
try {
|
||||
// Create an agent that uses the MCP tools
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<company name="MidSizeCorp" founded="2008">
|
||||
<division name="Engineering" head="Dana White">
|
||||
<department name="Frontend" lead="Alex Kim">
|
||||
<team name="Web">
|
||||
<employee id="E01">
|
||||
<name>Jordan Lee</name>
|
||||
<role>Lead Developer</role>
|
||||
<projects>
|
||||
<project code="PRJ101" status="active">
|
||||
<title>User Portal</title>
|
||||
<deadline>2025-08-01</deadline>
|
||||
<tasks>
|
||||
<task id="T1011">
|
||||
<description>Implement login page</description>
|
||||
<due>2025-05-10</due>
|
||||
</task>
|
||||
<task id="T1012">
|
||||
<description>Design dashboard</description>
|
||||
<due>2025-05-20</due>
|
||||
</task>
|
||||
</tasks>
|
||||
</project>
|
||||
</projects>
|
||||
</employee>
|
||||
<employee id="E02">
|
||||
<name>Riley Chen</name>
|
||||
<role>UI Designer</role>
|
||||
</employee>
|
||||
</team>
|
||||
<team name="Mobile">
|
||||
<employee id="E03">
|
||||
<name>Sam Patel</name>
|
||||
<role>iOS Developer</role>
|
||||
</employee>
|
||||
</team>
|
||||
</department>
|
||||
<department name="Backend" lead="Morgan Reed">
|
||||
<team name="API">
|
||||
<employee id="E04">
|
||||
<name>Taylor Jones</name>
|
||||
<role>API Engineer</role>
|
||||
</employee>
|
||||
</team>
|
||||
<team name="Database">
|
||||
<employee id="E05">
|
||||
<name>Casey Nguyen</name>
|
||||
<role>DB Administrator</role>
|
||||
</employee>
|
||||
</team>
|
||||
</department>
|
||||
</division>
|
||||
|
||||
<division name="Marketing" head="Pat Morgan">
|
||||
<department name="Digital" lead="Alex Rivera">
|
||||
<team name="Content">
|
||||
<employee id="M01">
|
||||
<name>Charlie Brooks</name>
|
||||
<role>Content Strategist</role>
|
||||
</employee>
|
||||
</team>
|
||||
</department>
|
||||
</division>
|
||||
|
||||
<headquarters location="Chicago, USA">
|
||||
<address>
|
||||
<street>789 Lake Shore Drive</street>
|
||||
<city>Chicago</city>
|
||||
<zip>60601</zip>
|
||||
</address>
|
||||
</headquarters>
|
||||
</company>
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/examples",
|
||||
"version": "0.3.23",
|
||||
"version": "0.3.24",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
@@ -44,11 +44,11 @@
|
||||
"@llamaindex/portkey-ai": "^0.0.53",
|
||||
"@llamaindex/postgres": "^0.0.54",
|
||||
"@llamaindex/qdrant": "^0.1.21",
|
||||
"@llamaindex/readers": "^3.1.9",
|
||||
"@llamaindex/readers": "^3.1.10",
|
||||
"@llamaindex/replicate": "^0.0.53",
|
||||
"@llamaindex/supabase": "^0.1.10",
|
||||
"@llamaindex/together": "^0.0.21",
|
||||
"@llamaindex/tools": "^0.0.17",
|
||||
"@llamaindex/tools": "^0.1.0",
|
||||
"@llamaindex/upstash": "^0.0.25",
|
||||
"@llamaindex/vercel": "^0.1.11",
|
||||
"@llamaindex/vllm": "^0.0.47",
|
||||
@@ -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",
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
"start:llamaparse-json": "node --import tsx ./src/llamaparse-json.ts",
|
||||
"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:obsidian": "node --import tsx ./src/obsidian.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);
|
||||
@@ -0,0 +1,16 @@
|
||||
import { XMLReader } from "@llamaindex/readers/xml";
|
||||
|
||||
async function main() {
|
||||
// Load PDF
|
||||
const reader = new XMLReader({
|
||||
splitLevel: 2,
|
||||
});
|
||||
const documents = await reader.loadData("../data/company.xml");
|
||||
|
||||
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:*",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/readers
|
||||
|
||||
## 3.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c5846bd: feat(readers): add XMLReader for parsing XML files (#1846)
|
||||
|
||||
## 3.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/readers",
|
||||
"description": "LlamaIndex Readers",
|
||||
"version": "3.1.9",
|
||||
"version": "3.1.10",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./node/hook": "./node/dist/hook.js",
|
||||
@@ -129,6 +129,16 @@
|
||||
"types": "./text/dist/index.d.ts",
|
||||
"default": "./text/dist/index.js"
|
||||
}
|
||||
},
|
||||
"./xml": {
|
||||
"require": {
|
||||
"types": "./xml/dist/index.d.cts",
|
||||
"default": "./xml/dist/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./xml/dist/index.d.ts",
|
||||
"default": "./xml/dist/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -142,7 +152,8 @@
|
||||
"obsidian",
|
||||
"pdf",
|
||||
"text",
|
||||
"node"
|
||||
"node",
|
||||
"xml"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -166,6 +177,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@discoveryjs/json-ext": "^0.6.1",
|
||||
"@xmldom/xmldom": "^0.9.8",
|
||||
"csv-parse": "^5.5.6",
|
||||
"mammoth": "^1.7.2",
|
||||
"unpdf": "^0.12.1"
|
||||
|
||||
@@ -7,6 +7,8 @@ import { ImageReader } from "../image";
|
||||
import { MarkdownReader } from "../markdown";
|
||||
import { PDFReader } from "../pdf";
|
||||
import { TextFileReader } from "../text";
|
||||
import { XMLReader } from "../xml";
|
||||
|
||||
import {
|
||||
AbstractSimpleDirectoryReader,
|
||||
type SimpleDirectoryReaderLoadDataParams,
|
||||
@@ -24,6 +26,7 @@ export const FILE_EXT_TO_READER: Record<string, FileReader> = {
|
||||
jpeg: new ImageReader(),
|
||||
png: new ImageReader(),
|
||||
gif: new ImageReader(),
|
||||
xml: new XMLReader(),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import { Document, FileReader } from "@llamaindex/core/schema";
|
||||
import {
|
||||
DOMParser,
|
||||
XMLSerializer,
|
||||
Document as XmlDocument,
|
||||
Element as XmlElement,
|
||||
} from "@xmldom/xmldom";
|
||||
|
||||
export class XMLReader extends FileReader<Document> {
|
||||
private splitLevel: number;
|
||||
|
||||
/**
|
||||
* @param splitLevel how deep to split the XML tree
|
||||
*/
|
||||
|
||||
constructor({ splitLevel }: { splitLevel?: number } = {}) {
|
||||
super();
|
||||
this.splitLevel = splitLevel ?? 0;
|
||||
}
|
||||
|
||||
/** XMLParser */
|
||||
async loadDataAsContent(fileContent: Uint8Array): Promise<Document[]> {
|
||||
const xmlStr = new TextDecoder().decode(fileContent);
|
||||
const doc: XmlDocument = new DOMParser().parseFromString(
|
||||
xmlStr,
|
||||
"application/xml",
|
||||
);
|
||||
|
||||
if (!doc || !doc.documentElement) {
|
||||
throw new Error("Invalid XML: unable to parse document");
|
||||
}
|
||||
|
||||
const root: XmlElement = doc.documentElement!;
|
||||
|
||||
return this._parseElementToDocuments(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: split tree into leaf or level-matched nodes
|
||||
*/
|
||||
private _getLeafNodesUpToLevel(
|
||||
root: XmlElement,
|
||||
level: number,
|
||||
): XmlElement[] {
|
||||
const result: XmlElement[] = [];
|
||||
const traverse = (node: XmlElement, currLevel: number) => {
|
||||
const children = Array.from(node.childNodes).filter(
|
||||
(n) => n.nodeType === n.ELEMENT_NODE,
|
||||
) as XmlElement[];
|
||||
if (children.length === 0 || currLevel === level) {
|
||||
result.push(node);
|
||||
} else {
|
||||
for (const child of children) {
|
||||
traverse(child, currLevel + 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
traverse(root, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
private _parseElementToDocuments(root: XmlElement): Document[] {
|
||||
const nodes = this._getLeafNodesUpToLevel(root, this.splitLevel);
|
||||
const serializer = new XMLSerializer();
|
||||
return nodes.map(
|
||||
(node) =>
|
||||
new Document({ text: serializer.serializeToString(node).trim() }),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"edge-light": "./dist/index.edge-light.js",
|
||||
"workerd": "./dist/index.workerd.js",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/tools
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 096bf2b: Add support for StreamableHTTP mcp client
|
||||
|
||||
## 0.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/tools",
|
||||
"description": "LlamaIndex Tools",
|
||||
"version": "0.0.17",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
@@ -47,13 +47,13 @@
|
||||
"dependencies": {
|
||||
"@apidevtools/swagger-parser": "^10.1.0",
|
||||
"@e2b/code-interpreter": "^1.0.4",
|
||||
"@modelcontextprotocol/sdk": "^1.8.0",
|
||||
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||
"duck-duck-scrape": "^2.2.5",
|
||||
"formdata-node": "^6.0.3",
|
||||
"got": "^14.4.1",
|
||||
"marked": "^14.1.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"wikipedia": "^2.1.2",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.25.67"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ import {
|
||||
StdioClientTransport,
|
||||
type StdioServerParameters,
|
||||
} from "@modelcontextprotocol/sdk/client/stdio.js";
|
||||
import {
|
||||
StreamableHTTPClientTransport,
|
||||
type StreamableHTTPClientTransportOptions,
|
||||
} from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
||||
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
|
||||
import type { JSONSchemaType } from "ajv";
|
||||
|
||||
@@ -36,17 +40,37 @@ type MCPCommonOptions = {
|
||||
verbose?: boolean;
|
||||
};
|
||||
|
||||
type StdioMCPClientOptions = StdioServerParameters & MCPCommonOptions;
|
||||
type SSEMCPClientOptions = SSEClientTransportOptions &
|
||||
MCPCommonOptions & {
|
||||
url: string;
|
||||
};
|
||||
type URLMCPOptions = MCPCommonOptions & {
|
||||
url: string;
|
||||
/**
|
||||
* Default is false which means StreamableHTTP transport will be used.
|
||||
* Set to true to use SSE transport instead.
|
||||
* @default false
|
||||
* @deprecated SSE transport will be soon deprecated. Please use StreamableHTTP transport instead.
|
||||
*/
|
||||
useSSETransport?: boolean;
|
||||
};
|
||||
|
||||
type MCPClientOptions = StdioMCPClientOptions | SSEMCPClientOptions;
|
||||
type StdioMCPClientOptions = StdioServerParameters & MCPCommonOptions;
|
||||
/**
|
||||
* @deprecated SSE transport will be soon deprecated. Please use StreamableHTTPMCPClientOptions instead.
|
||||
*/
|
||||
type SSEMCPClientOptions = SSEClientTransportOptions & URLMCPOptions;
|
||||
type StreamableHTTPMCPClientOptions = StreamableHTTPClientTransportOptions &
|
||||
URLMCPOptions;
|
||||
|
||||
type MCPClientOptions =
|
||||
| StdioMCPClientOptions
|
||||
| SSEMCPClientOptions
|
||||
| StreamableHTTPMCPClientOptions;
|
||||
|
||||
class MCPClient {
|
||||
private mcp: Client;
|
||||
private transport: StdioClientTransport | SSEClientTransport | null = null;
|
||||
private transport:
|
||||
| StreamableHTTPClientTransport
|
||||
| SSEClientTransport
|
||||
| StdioClientTransport
|
||||
| null = null;
|
||||
private verbose: boolean;
|
||||
private toolNamePrefix?: string | undefined;
|
||||
private connected: boolean = false;
|
||||
@@ -60,10 +84,23 @@ class MCPClient {
|
||||
this.verbose = options.verbose ?? false;
|
||||
this.toolNamePrefix = options.toolNamePrefix;
|
||||
if ("url" in options) {
|
||||
this.transport = new SSEClientTransport(
|
||||
new URL(options.url),
|
||||
options as SSEClientTransportOptions,
|
||||
);
|
||||
const useSSETransport = options.useSSETransport ?? false;
|
||||
if (useSSETransport) {
|
||||
// Show deprecation warning
|
||||
console.warn(
|
||||
"SSE transport will be soon deprecated. " +
|
||||
"Please use StreamableHTTPClientTransport instead",
|
||||
);
|
||||
this.transport = new SSEClientTransport(
|
||||
new URL(options.url),
|
||||
options as SSEClientTransportOptions,
|
||||
);
|
||||
} else {
|
||||
this.transport = new StreamableHTTPClientTransport(
|
||||
new URL(options.url),
|
||||
options as StreamableHTTPClientTransportOptions,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.transport = new StdioClientTransport(
|
||||
options as StdioServerParameters,
|
||||
@@ -79,6 +116,8 @@ class MCPClient {
|
||||
if (!this.transport) {
|
||||
throw new Error("Initialized with invalid options");
|
||||
}
|
||||
// @ts-expect-error - to mitigate exactOptionalPropertyTypes error
|
||||
// that we have sessionId: string | undefined from the transport
|
||||
await this.mcp.connect(this.transport);
|
||||
this.connected = true;
|
||||
}
|
||||
|
||||
@@ -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
+282
-234
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,20 @@
|
||||
# @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
|
||||
|
||||
- Updated dependencies [c5846bd]
|
||||
- @llamaindex/readers@3.1.10
|
||||
|
||||
## 0.1.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/unit-test",
|
||||
"private": true,
|
||||
"version": "0.1.37",
|
||||
"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