llamaindex
Version:
<p align="center"> <img height="100" width="100" alt="LlamaIndex logo" src="https://ts.llamaindex.ai/square.svg" /> </p> <h1 align="center">LlamaIndex.TS</h1> <h3 align="center"> Data framework for your LLM application. </h3>
137 lines (129 loc) • 5.32 kB
TypeScript
import * as _llamaindex_cloud_api from '@llamaindex/cloud/api';
import { RetrievalParams, MetadataFilters, PipelineCreateReadable } from '@llamaindex/cloud/api';
import { BaseNodePostprocessor } from '@llamaindex/core/postprocessor';
import { QueryBundle, BaseQueryEngine } from '@llamaindex/core/query-engine';
import { BaseSynthesizer } from '@llamaindex/core/response-synthesizers';
import { NodeWithScore, Document } from '@llamaindex/core/schema';
import { BaseRetriever } from '@llamaindex/core/retriever';
import { BaseTool, ToolMetadata } from '@llamaindex/core/llms';
import { JSONSchemaType } from 'ajv';
import { JSONValue } from '@llamaindex/core/global';
declare class LLamaCloudFileService {
/**
* Get list of projects, each project contains a list of pipelines
*/
static getAllProjectsWithPipelines(): Promise<{
pipelines: _llamaindex_cloud_api.PipelineReadable[];
name: string;
id: string;
created_at?: string | null;
updated_at?: string | null;
ad_hoc_eval_dataset_id?: string | null;
organization_id: string;
is_default?: boolean;
}[]>;
/**
* Upload a file to a pipeline in LlamaCloud
*/
static addFileToPipeline(projectId: string, pipelineId: string, uploadFile: File | Blob, customMetadata?: Record<string, any>): Promise<string>;
/**
* Get download URL for a file in LlamaCloud
*/
static getFileUrl(pipelineId: string, filename: string): Promise<string | null>;
}
type ClientParams = {
apiKey?: string | undefined;
baseUrl?: string | undefined;
};
type CloudConstructorParams = {
name: string;
projectName: string;
organizationId?: string | undefined;
} & ClientParams;
type CloudRetrieveParams = Omit<RetrievalParams, "query" | "search_filters" | "dense_similarity_top_k"> & {
similarityTopK?: number;
filters?: MetadataFilters;
};
declare class LlamaCloudRetriever extends BaseRetriever {
clientParams: ClientParams;
retrieveParams: CloudRetrieveParams;
organizationId?: string;
projectName: string;
pipelineName: string;
private resultNodesToNodeWithScore;
private convertFilter;
constructor(params: CloudConstructorParams & CloudRetrieveParams);
_retrieve(query: QueryBundle): Promise<NodeWithScore[]>;
}
type QueryEngineToolParams = {
queryEngine: BaseQueryEngine;
metadata?: ToolMetadata<JSONSchemaType<QueryEngineParam>> | undefined;
includeSourceNodes?: boolean;
};
type QueryEngineParam = {
query: string;
};
declare class QueryEngineTool implements BaseTool<QueryEngineParam> {
private queryEngine;
metadata: ToolMetadata<JSONSchemaType<QueryEngineParam>>;
includeSourceNodes: boolean;
constructor({ queryEngine, metadata, includeSourceNodes, }: QueryEngineToolParams);
call({ query }: QueryEngineParam): Promise<JSONValue>;
}
/**
* Common parameter type for queryTool and asQueryTool
*/
type QueryToolParams = ({
options: any;
retriever?: never;
} | {
options?: never;
retriever?: BaseRetriever;
}) & {
responseSynthesizer?: BaseSynthesizer;
metadata?: ToolMetadata<JSONSchemaType<QueryEngineParam>> | undefined;
includeSourceNodes?: boolean;
};
declare class LlamaCloudIndex {
params: CloudConstructorParams;
constructor(params: CloudConstructorParams);
private waitForPipelineIngestion;
private waitForDocumentIngestion;
getPipelineId(name?: string, projectName?: string, organizationId?: string): Promise<string>;
getProjectId(projectName?: string, organizationId?: string): Promise<string>;
/**
* Adds documents to the given index parameters. If the index does not exist, it will be created.
*
* @param params - An object containing the following properties:
* - documents: An array of Document objects to be added to the index.
* - verbose: Optional boolean to enable verbose logging.
* - Additional properties from CloudConstructorParams.
* @returns A Promise that resolves to a new LlamaCloudIndex instance.
*/
static fromDocuments(params: {
documents: Document[];
verbose?: boolean;
} & CloudConstructorParams, config?: {
embedding: PipelineCreateReadable["embedding_config"];
transform: PipelineCreateReadable["transform_config"];
}): Promise<LlamaCloudIndex>;
addDocuments(documents: Document[], verbose?: boolean): Promise<void>;
asRetriever(params?: CloudRetrieveParams): BaseRetriever;
asQueryEngine(params?: {
responseSynthesizer?: BaseSynthesizer;
preFilters?: unknown;
nodePostprocessors?: BaseNodePostprocessor[];
} & CloudRetrieveParams): BaseQueryEngine;
asQueryTool(params: QueryToolParams): QueryEngineTool;
queryTool(params: QueryToolParams): QueryEngineTool;
insert(document: Document): Promise<void>;
delete(document: Document): Promise<void>;
refreshDoc(document: Document): Promise<void>;
ensureIndex(config?: {
embedding?: PipelineCreateReadable["embedding_config"];
transform?: PipelineCreateReadable["transform_config"];
verbose?: boolean;
}): Promise<void>;
}
export { LLamaCloudFileService, LlamaCloudIndex, LlamaCloudRetriever };
export type { CloudConstructorParams, CloudRetrieveParams };