Compare commits

..

4 Commits

Author SHA1 Message Date
github-actions[bot] 1782554488 Release 0.11.18 (#2103)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-07-14 15:53:20 -07:00
Adrian Lyjak a1b1598bc6 fix(cloud): add generic types into agent data responses (#2102)
Co-authored-by: Alex Yang <himself65@outlook.com>
2025-07-14 12:01:56 -07:00
Terry Zhao b02847ae91 fix(notion): resolve @notionhq/client dependency conflict (#2097) 2025-07-12 11:04:06 -07:00
Alex Yang 50acb4821e feat(cloud): use camelCase (#2096) 2025-07-12 10:59:46 -07:00
34 changed files with 421 additions and 93 deletions
+8
View File
@@ -1,5 +1,13 @@
# @llamaindex/doc
## 0.2.39
### Patch Changes
- Updated dependencies [a1b1598]
- @llamaindex/cloud@4.0.23
- llamaindex@0.11.18
## 0.2.38
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/doc",
"version": "0.2.38",
"version": "0.2.39",
"private": true,
"scripts": {
"postinstall": "fumadocs-mdx",
@@ -1,5 +1,11 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.179
### Patch Changes
- llamaindex@0.11.18
## 0.0.178
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.178",
"version": "0.0.179",
"type": "module",
"private": true,
"scripts": {
@@ -1,5 +1,12 @@
# @llamaindex/llama-parse-browser-test
## 0.0.78
### Patch Changes
- Updated dependencies [a1b1598]
- @llamaindex/cloud@4.0.23
## 0.0.77
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.77",
"version": "0.0.78",
"type": "module",
"scripts": {
"dev": "vite",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/next-agent-test
## 0.1.179
### Patch Changes
- llamaindex@0.11.18
## 0.1.178
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.178",
"version": "0.1.179",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# test-edge-runtime
## 0.1.178
### Patch Changes
- llamaindex@0.11.18
## 0.1.177
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.177",
"version": "0.1.178",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# @llamaindex/next-node-runtime
## 0.1.47
### Patch Changes
- llamaindex@0.11.18
## 0.1.46
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.1.46",
"version": "0.1.47",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# vite-import-llamaindex
## 0.0.45
### Patch Changes
- llamaindex@0.11.18
## 0.0.44
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "vite-import-llamaindex",
"private": true,
"version": "0.0.44",
"version": "0.0.45",
"type": "module",
"scripts": {
"build": "vite build",
@@ -1,5 +1,11 @@
# @llamaindex/waku-query-engine-test
## 0.0.179
### Patch Changes
- llamaindex@0.11.18
## 0.0.178
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.178",
"version": "0.0.179",
"type": "module",
"private": true,
"scripts": {
+5
View File
@@ -43,6 +43,11 @@
"vitest": "^3.1.1"
},
"packageManager": "pnpm@10.8.1",
"pnpm": {
"overrides": {
"@notionhq/client": "4.0.0"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/autotool
## 8.0.18
### Patch Changes
- llamaindex@0.11.18
## 8.0.17
### Patch Changes
@@ -1,5 +1,12 @@
# @llamaindex/autotool-01-node-example
## 0.0.126
### Patch Changes
- llamaindex@0.11.18
- @llamaindex/autotool@8.0.18
## 0.0.125
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.125"
"version": "0.0.126"
}
+1 -1
View File
@@ -6,7 +6,7 @@
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/autotool"
},
"version": "8.0.17",
"version": "8.0.18",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/cloud
## 4.0.23
### Patch Changes
- a1b1598: fix: add generic types into agent data responses
## 4.0.22
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "4.0.22",
"version": "4.0.23",
"type": "module",
"license": "MIT",
"scripts": {
+188 -54
View File
@@ -8,19 +8,16 @@ import {
searchAgentDataApiV1BetaAgentDataSearchPost,
updateAgentDataApiV1BetaAgentDataItemIdPut,
type AgentData,
type AggregateRequest,
type PaginatedResponseAgentData,
type PaginatedResponseAggregateGroup,
type SearchRequest,
type AggregateGroup,
} from "../../client";
type AgentClientOptions = {
apiKey?: string;
baseUrl?: string;
collection?: string;
agentUrlId?: string;
windowUrl?: string;
};
import type {
AggregateAgentDataOptions,
SearchAgentDataOptions,
TypedAgentData,
TypedAgentDataItems,
TypedAggregateGroup,
TypedAggregateGroupItems,
} from "./types";
/**
* Async client for agent data operations
@@ -32,26 +29,18 @@ export class AgentClient<T = unknown> {
private collection: string;
private agentUrlId: string;
constructor(options: AgentClientOptions = {}) {
// Handle windowUrl to infer agentUrlId
let inferredAgentUrlId: string | undefined;
if (options.windowUrl && !options.agentUrlId) {
try {
const path = new URL(options.windowUrl).pathname;
// /deployments/<agent-url-id>/ui/ -> ["", "deployments", "<agent-url-id>", "ui"]
inferredAgentUrlId = path.split("/")[2];
} catch (error) {
console.warn(
"Failed to infer agent url id from window url, falling back to default",
error,
);
}
}
this.collection = options.collection || "default";
this.agentUrlId = options.agentUrlId || inferredAgentUrlId || "default";
const apiKey = options?.apiKey || getEnv("LLAMA_CLOUD_API_KEY");
this.baseUrl = options?.baseUrl || "https://api.cloud.llamaindex.ai/";
constructor({
apiKey = getEnv("LLAMA_CLOUD_API_KEY"),
baseUrl = "https://api.cloud.llamaindex.ai/",
collection = "default",
agentUrlId = "default",
}: {
apiKey?: string;
baseUrl?: string;
collection?: string;
agentUrlId?: string;
}) {
this.baseUrl = baseUrl;
this.headers = {
"X-SDK-Name": "llamaindex-ts",
@@ -64,29 +53,32 @@ export class AgentClient<T = unknown> {
headers: this.headers,
}),
);
this.collection = collection;
this.agentUrlId = agentUrlId;
}
/**
* Create new agent data
*/
async createItem(data: T): Promise<AgentData> {
async createItem(data: T): Promise<TypedAgentData<T>> {
const response = await createAgentDataApiV1BetaAgentDataPost({
throwOnError: true,
body: {
collection: this.collection,
agent_slug: this.agentUrlId,
collection: this.collection,
data: data as Record<string, unknown>,
},
client: this.client,
});
return response.data;
return this.transformResponse(response.data);
}
/**
* Get agent data by ID
*/
async getItem(id: string): Promise<AgentData | null> {
async getItem(id: string): Promise<TypedAgentData<T> | null> {
try {
const response = await getAgentDataApiV1BetaAgentDataItemIdGet({
throwOnError: true,
@@ -94,7 +86,7 @@ export class AgentClient<T = unknown> {
client: this.client,
});
return response.data;
return this.transformResponse(response.data);
} catch (error) {
if (
error instanceof Error &&
@@ -110,7 +102,7 @@ export class AgentClient<T = unknown> {
/**
* Update agent data
*/
async updateItem(id: string, data: T): Promise<AgentData> {
async updateItem(id: string, data: T): Promise<TypedAgentData<T>> {
const response = await updateAgentDataApiV1BetaAgentDataItemIdPut({
throwOnError: true,
path: { item_id: id },
@@ -120,7 +112,7 @@ export class AgentClient<T = unknown> {
client: this.client,
});
return response.data;
return this.transformResponse(response.data);
}
/**
@@ -135,46 +127,188 @@ export class AgentClient<T = unknown> {
}
/**
* Search agent data
* List agent data
*/
async search(
options: Partial<SearchRequest> = {},
): Promise<PaginatedResponseAgentData> {
options: SearchAgentDataOptions,
): Promise<TypedAgentDataItems<T>> {
const response = await searchAgentDataApiV1BetaAgentDataSearchPost({
throwOnError: true,
body: {
...options,
agent_slug: this.agentUrlId,
collection: this.collection,
...(this.collection !== undefined && {
collection: this.collection,
}),
...(options.filter !== undefined && { filter: options.filter }),
...(options.orderBy !== undefined && { order_by: options.orderBy }),
...(options.pageSize !== undefined && { page_size: options.pageSize }),
...(options.offset !== undefined && { offset: options.offset }),
...(options.includeTotal !== undefined && {
include_total: options.includeTotal,
}),
},
client: this.client,
});
return response.data;
const result: TypedAgentDataItems<T> = {
items: response.data.items.map((item: AgentData) =>
this.transformResponse(item),
),
};
if (
response.data.total_size !== null &&
response.data.total_size !== undefined
) {
result.totalSize = response.data.total_size;
}
if (
response.data.next_page_token !== null &&
response.data.next_page_token !== undefined
) {
result.nextPageToken = response.data.next_page_token;
}
return result;
}
/**
* Aggregate agent data into groups
*/
async aggregate(
options: Partial<AggregateRequest> = {},
): Promise<PaginatedResponseAggregateGroup> {
options: AggregateAgentDataOptions,
): Promise<TypedAggregateGroupItems<T>> {
const response = await aggregateAgentDataApiV1BetaAgentDataAggregatePost({
throwOnError: true,
body: {
...options,
agent_slug: this.agentUrlId,
collection: this.collection,
...(this.collection !== undefined && {
collection: this.collection,
}),
...(options.filter !== undefined && { filter: options.filter }),
...(options.groupBy !== undefined && { group_by: options.groupBy }),
...(options.count !== undefined && { count: options.count }),
...(options.first !== undefined && { first: options.first }),
...(options.orderBy !== undefined && { order_by: options.orderBy }),
...(options.offset !== undefined && { offset: options.offset }),
...(options.pageSize !== undefined && { page_size: options.pageSize }),
},
client: this.client,
});
return response.data;
const result: TypedAggregateGroupItems<T> = {
items: response.data.items.map((item) =>
this.transformAggregateResponse(item),
),
};
if (
response.data.total_size !== null &&
response.data.total_size !== undefined
) {
result.totalSize = response.data.total_size;
}
if (
response.data.next_page_token !== null &&
response.data.next_page_token !== undefined
) {
result.nextPageToken = response.data.next_page_token;
}
return result;
}
/**
* Transform API response to typed data
*/
private transformResponse(data: AgentData): TypedAgentData<T> {
const result: TypedAgentData<T> = {
id: data.id!,
agentUrlId: data.agent_slug,
data: data.data as T,
createdAt: new Date(data.created_at!),
updatedAt: new Date(data.updated_at!),
};
if (data.collection !== undefined) {
result.collection = data.collection;
}
return result;
}
/**
* Transform API aggregate response to typed data
*/
private transformAggregateResponse(
data: AggregateGroup,
): TypedAggregateGroup<T> {
const result: TypedAggregateGroup<T> = {
groupKey: data.group_key,
};
if (data.count !== null && data.count !== undefined) {
result.count = data.count;
}
if (data.first_item !== null && data.first_item !== undefined) {
result.firstItem = data.first_item as T;
}
return result;
}
}
export function createAgentDataClient<T = unknown>(
options: AgentClientOptions = {},
): AgentClient<T> {
return new AgentClient<T>(options);
export interface AgentDataClientOptions<T = unknown> {
/** API key for the client */
apiKey?: string;
/** Base URL for the client */
/** Base URL of the llama cloud api */
baseUrl?: string;
/** If running in an agent runtime, optionally provide the window url to infer the agent url id */
windowUrl?: string;
/** Agent URL ID for the client, if not provided, it will be inferred from the window url, or fall back to "default" */
agentUrlId?: string;
/** Collection name for the client, defaults to "default" */
collection?: string;
}
/**
* Create a new AsyncAgentDataClient instance
* @param options - The options for the client
* @returns A new AgentClient instance
*/
export function createAgentDataClient<T = unknown>({
apiKey,
baseUrl,
windowUrl,
agentUrlId,
collection = "default",
}: {
apiKey?: string;
baseUrl?: string;
windowUrl?: string;
agentUrlId?: string;
collection?: string;
} = {}): AgentClient<T> {
if (windowUrl && !agentUrlId) {
try {
const path = new URL(windowUrl).pathname;
// /deployments/<agent-url-id>/ui/ -> ["", "deployments", "<agent-url-id>", "ui"]
agentUrlId = path.split("/")[2];
} catch (error) {
console.warn(
"Failed to infer agent url id from window url, falling back to default",
error,
);
}
}
return new AgentClient({
...(apiKey && { apiKey }),
...(baseUrl && { baseUrl }),
...(agentUrlId && { agentUrlId }),
collection,
});
}
+7 -6
View File
@@ -1,15 +1,16 @@
export { AgentClient, createAgentDataClient } from "./client";
export type {
AgentData,
AggregateGroup,
AggregateRequest,
AggregateAgentDataOptions,
ComparisonOperator,
ExtractedData,
FilterOperation,
PaginatedResponseAgentData,
PaginatedResponseAggregateGroup,
SearchRequest,
SearchAgentDataOptions,
StatusType,
TypedAgentData,
TypedAgentDataItems,
TypedAggregateGroup,
TypedAggregateGroupItems,
} from "./types";
export { StatusType as StatusTypeEnum } from "./types";
+105 -11
View File
@@ -1,14 +1,4 @@
// Re-export types from the client
export type {
AgentData,
AggregateGroup,
AggregateRequest,
FilterOperation,
PaginatedResponseAgentData,
PaginatedResponseAggregateGroup,
SearchRequest,
} from "../../client";
import type { FilterOperation as RawFilterOperation } from "../../client/types.gen";
/**
* Status types for agent data processing
*/
@@ -21,6 +11,23 @@ export const StatusType = {
export type StatusType = (typeof StatusType)[keyof typeof StatusType];
export const ComparisonOperator = {
GT: "gt",
GTE: "gte",
LT: "lt",
LTE: "lte",
EQ: "eq",
INCLUDES: "includes",
} as const;
export type ComparisonOperator =
(typeof ComparisonOperator)[keyof typeof ComparisonOperator];
/**
* Filter operation for searching/filtering agent data
*/
export type FilterOperation = RawFilterOperation;
/**
* Base extracted data interface
*/
@@ -42,3 +49,90 @@ export interface ExtractedData<T = unknown> {
/** Additional metadata about the extracted data, such as errors, tokens, etc. */
metadata?: Record<string, unknown>;
}
/**
* TypedAgentData interface for typed agent data
*/
export interface TypedAgentData<T = unknown> {
/** The unique ID of the agent data record. */
id: string;
/** The ID of the agent that created the data. */
agentUrlId: string;
/** The collection of the agent data. */
collection?: string;
/** The data of the agent data. Usually an ExtractedData&lt;SomeOtherType&gt; */
data: T;
/** The date and time the data was created. */
createdAt: Date;
/** The date and time the data was last updated. */
updatedAt: Date;
}
/**
* Paginated response of typed agent data items
*/
export interface TypedAgentDataItems<T = unknown> {
items: TypedAgentData<T>[];
totalSize?: number;
nextPageToken?: string;
}
/**
* Options for listing agent data
*/
export interface SearchAgentDataOptions {
/** Filter options for the list. */
filter?: Record<string, FilterOperation>;
/** Order by options for the list. */
orderBy?: string;
/** Page size for the list. */
pageSize?: number;
/** Offset for the list. */
offset?: number;
/**
* Whether to include the total number of items in the response.
* Should use only for first request to build total pagination, and not subsequent requests.
*/
includeTotal?: boolean;
}
/**
* Options for aggregating agent data
*/
export interface AggregateAgentDataOptions {
/** Filter options for the aggregation. */
filter?: Record<string, FilterOperation>;
/** Fields to group by. */
groupBy?: string[];
/** Whether to count the number of items in each group. */
count?: boolean;
/** Whether to return the first item in each group. */
first?: boolean;
/** Order by options for the aggregation. */
orderBy?: string;
/** Offset for the aggregation. */
offset?: number;
/** Page size for the aggregation. */
pageSize?: number;
}
/**
* Single aggregation group result
*/
export interface TypedAggregateGroup<T = unknown> {
/** The group key values */
groupKey: Record<string, unknown>;
/** Count of items in the group */
count?: number;
/** First item in the group */
firstItem?: T;
}
/**
* Paginated response of aggregated agent data
*/
export interface TypedAggregateGroupItems<T = unknown> {
items: TypedAggregateGroup<T>[];
totalSize?: number;
nextPageToken?: string;
}
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/experimental
## 0.0.195
### Patch Changes
- llamaindex@0.11.18
## 0.0.194
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.194",
"version": "0.0.195",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+7
View File
@@ -1,5 +1,12 @@
# llamaindex
## 0.11.18
### Patch Changes
- Updated dependencies [a1b1598]
- @llamaindex/cloud@4.0.23
## 0.11.17
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.11.17",
"version": "0.11.18",
"license": "MIT",
"type": "module",
"keywords": [
+3 -3
View File
@@ -26,12 +26,12 @@
},
"devDependencies": {
"@llamaindex/core": "workspace:*",
"@llamaindex/env": "workspace:*",
"@notionhq/client": "^4.0.0"
"@llamaindex/env": "workspace:*"
},
"peerDependencies": {
"@llamaindex/core": "workspace:*",
"@llamaindex/env": "workspace:*"
"@llamaindex/env": "workspace:*",
"@notionhq/client": "^4.0.0"
},
"dependencies": {
"notion-md-crawler": "^1.0.2"
+8 -5
View File
@@ -4,6 +4,9 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
overrides:
'@notionhq/client': 4.0.0
importers:
.:
@@ -750,7 +753,7 @@ importers:
specifier: ^0.0.11
version: link:../packages/providers/xai
'@notionhq/client':
specifier: ^4.0.0
specifier: 4.0.0
version: 4.0.0
'@pinecone-database/pinecone':
specifier: ^4.0.0
@@ -854,7 +857,7 @@ importers:
specifier: workspace:* || ^1.0.25
version: link:../../packages/readers
'@notionhq/client':
specifier: ^4.0.0
specifier: 4.0.0
version: 4.0.0
llamaindex:
specifier: workspace:* || ^0.8.37
@@ -1365,6 +1368,9 @@ importers:
packages/providers/notion:
dependencies:
'@notionhq/client':
specifier: 4.0.0
version: 4.0.0
notion-md-crawler:
specifier: ^1.0.2
version: 1.0.2
@@ -1375,9 +1381,6 @@ importers:
'@llamaindex/env':
specifier: workspace:*
version: link:../../env
'@notionhq/client':
specifier: ^4.0.0
version: 4.0.0
packages/providers/ollama:
dependencies:
+8
View File
@@ -1,5 +1,13 @@
# @llamaindex/unit-test
## 0.1.47
### Patch Changes
- Updated dependencies [a1b1598]
- @llamaindex/cloud@4.0.23
- llamaindex@0.11.18
## 0.1.46
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/unit-test",
"private": true,
"version": "0.1.46",
"version": "0.1.47",
"type": "module",
"scripts": {
"test": "vitest run"