import * as _llamaindex_cloud_api from '@llamaindex/cloud/api';
import { RetrievalParams, MetadataFilters, PipelineCreate } 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 * as _llamaindex_core_llms from '@llamaindex/core/llms';
import { BaseTool, ToolMetadata } from '@llamaindex/core/llms';
import { JSONSchemaType } from 'ajv';
import * as _llamaindex_core_global 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.Pipeline[];
        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<string | number | boolean | _llamaindex_core_global.JSONObject | _llamaindex_core_global.JSONArray | {
        content: _llamaindex_core_llms.MessageContent;
    }>;
}

/**
 * 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: PipelineCreate["embedding_config"];
        transform: PipelineCreate["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?: PipelineCreate["embedding_config"];
        transform?: PipelineCreate["transform_config"];
        verbose?: boolean;
    }): Promise<void>;
}

export { type CloudConstructorParams, type CloudRetrieveParams, LLamaCloudFileService, LlamaCloudIndex, LlamaCloudRetriever };
