// Generated by dts-bundle-generator v8.1.2 import { AxiosInstance } from 'axios'; import { z } from 'zod'; declare const metadata: z.ZodDefault>>>>; export type MetadataType = z.infer; declare const SearchOptions: z.ZodObject<{ topK: z.ZodDefault; rerank: z.ZodDefault; field: z.ZodOptional; level: z.ZodDefault; }, "strip", z.ZodTypeAny, { topK: number; rerank: boolean; level: number; field?: string | undefined; }, { topK?: number | undefined; rerank?: boolean | undefined; field?: string | undefined; level?: number | undefined; }>; export type SearchOptions = z.input; declare const QueryOptions: z.ZodObject<{ topK: z.ZodDefault; }, "strip", z.ZodTypeAny, { topK: number; }, { topK?: number | undefined; }>; export type QueryOptions = z.input; declare const BatchTexts: z.ZodArray>>>>; }, "strip", z.ZodTypeAny, { text: string; metadata: Record; }, { text: string; metadata?: Record | undefined; }>, "many">; export type BatchTexts = { metadata: T; text: string; }[]; declare const BatchVectors: z.ZodArray; metadata: z.ZodDefault>>>>; }, "strip", z.ZodTypeAny, { metadata: Record; vector: number[]; }, { vector: number[]; metadata?: Record | undefined; }>, "many">; export type BatchVectors = { metadata: T; vector: number[]; }[]; /** Dria client parameters. */ export interface DriaParams { apiKey?: string; contractId?: string; } /** Model types supported by Dria, although this type allows any string. */ export type ModelTypes = "jina-embeddings-v2-base-en" | "jina-embeddings-v2-small-en" | "text-embedding-ada-002" | "text-embedding-3-small" | "text-embedding-3-large" | (string & NonNullable); /** Category types supported by Dria, although this type allows any string. */ export type CategoryTypes = "Art" | "Artificial Intelligence" | "Book" | "Business" | "Children" | "Crypto" | "Culture" | "Fantasy" | "Folklore & Mythology" | "Media" | "Health & Lifestyle" | "Medicine" | "History" | "Philosophy" | "Poetry" | "Psychology" | "Religion" | "Science" | "Sports" | "Technology" | "Software Development" | (string & NonNullable); declare class DriaCommon { protected readonly client: AxiosInstance; constructor(client: AxiosInstance); /** * A POST request wrapper. * @param url request URL * @param body request body * @template T type of response body * @returns parsed response body */ protected post(url: string, body: unknown): Promise; /** * A GET request wrapper. * @param url request URL * @param params query parameters * @template T type of response body * @returns parsed response body */ protected get(url: string, params?: Record): Promise; } /** * ## Dria Client * * @param params optional API key and contract ID. * * - `apiKey`: User API key. * * If not provided, Dria will look for `DRIA_API_KEY` on the environment. * To find your API key, go to your profile page at [Dria](https://dria.co/profile). * * - `contractId`: Contract ID for the knowledge, corresponding to the transaction id of a contract deployment on Arweave. * In [Dria](https://dria.co/profile), this can be seen at the top of the page when viewing a knowledge. * * @template T default type of metadata; a metadata in Dria is a single-level mapping, with string keys and values of type `string`, `number` * * @example * const dria = new Dria({ * apiKey: "your-api-key", * contractId: "your-contract" * }); * * @example * // provide metadata type * const dria = new Dria<{foo: string, bar: number}>({ * contractId: "your-contract" * // apiKey not provided here, so Dria will * // read it from env as `DRIA_API_KEY` * }); * * @example * const dria = new Dria(); * const contractId = await dria.create(); * dria.contractId = contractId; */ export declare class Dria extends DriaCommon { contractId: string | undefined; /** Cached contract models. */ private models; constructor(params?: DriaParams); /** A text-based search. * @param text search query text. * @param options search options: * - `topK`: number of results to return, max 20. (default: 10) * - `rerank`: re-rank the results from most to least semantically relevant to the given search query. (default: true) * - `level`: level of detail for the search, must be an integer from 0 to 5 (inclusive). (default: 1) * - `field`: CSV field name, only relevant for the CSV files. * @returns an array of `topK` results with id, metadata (string) and the relevancy score. * @example * const res = await dria.search("What is the great library of Alexandria?"); * console.log(res.metadata); */ search(text: string, options?: SearchOptions): Promise<{ id: number; metadata: string; score: number; }[]>; /** A vector-based query. * @param vector query vector. * @param options query options: * - `topK`: number of results to return. * @template M type of the metadata, defaults to type provided to the client. * @returns an array of `topK` results with id, metadata and the relevancy score. * @example * const res = await dria.query<{about: string}>([0.1, 0.92, ..., 0.16]); * console.log(res[0].metadata.about); */ query(vector: number[], options?: QueryOptions): Promise<{ metadata: M; id: number; score: number; }[]>; /** Fetch vectors with the given IDs. * @param ids an array of ids. * @template M type of the metadata, defaults to type provided to the client. * @returns an array of metadatas belonging to the given vector IDs. * @example * const res = await dria.fetch([0]) * console.log(res[0]) */ fetch(ids: number[]): Promise<{ metadata: M; vector: number[]; }[]>; /** * Insert a batch of vectors to your existing knowledge. * @param items batch of vectors with optional metadatas * @returns a string indicating success * @example * const batch = [ * {vector: [...], metadata: {}}, * {vector: [...], metadata: {foo: 'bar'}}, * // ... * ] * await dria.insertVectors(batch); */ insertVectors(items: BatchVectors): Promise; /** * Insert a batch of texts to your existing knowledge. * @param items batch of texts with optional metadatas * @returns a string indicating success * @example * const batch = [ * {text: "...", metadata: {}}, * {text: "...", metadata: {foo: 'bar'}}, * // ... * ] * await dria.insertTexts(batch); */ insertTexts(items: BatchTexts): Promise; /** Create a knowledge base index. * @param name name of the knowledge. * @param embedding model name, can be any string but we provide some preset models. * @param category type of the knowledge, can be any string but we provide some preset names. * @param description (optional) description of the knowledge. * @returns contract ID of the created contract. * @example * const dria = new Dria({apiKey: "your-api-key"}); * const contractId = await dria.create( * "My Contract", * "jinaai/jina-embeddings-v2-base-en", * "Science" * ) * dria.contractId = contractId; * // you can now make queries, or insert data there */ create(name: string, embedding: ModelTypes, category: CategoryTypes, description?: string): Promise; /** Delete a knowledge. * @param contractId contract ID of the knowledge. * @returns boolean that indicates success * @example * const dria = new Dria({apiKey: "your-api-key"}); * await dria.delete("your-contract-to-delete"); */ delete(contractId: string): Promise; /** Get the embedding model used by a contract. * @param contractId contract ID * @returns name of the embedding model used by the contract * @example * const model = await dria.getModel("contract-id-here"); * console.log(model); */ getModel(contractId: string): Promise; /** Safely gets the contract ID. * @returns currently configured contract ID, guaranteed to be not null */ private getContractId; } /** * ## Dria Local Client * * Dria local client is a convenience tool that allows one to use the served knowledge via [Dria Docker](https://github.com/firstbatchxyz/dria-docker). * The URL defaults to `http://localhost:8080`, but you can override it. * * Unlike the other Dria client, Dria local does not require an API key or a contract ID, since the locally served knowledge serves a single contract. * Furthermore, text-based input is not allowed as that requires an embedding model to be running on the side. * * @template T default type of metadata; a metadata in Dria is a single-level mapping, with string keys and values of type `string`, `number` * * @example * // connects to http://localhost:8080 * const dria = new DriaLocal(); * * @example * const dria = new DriaLocal("your-url"); */ export declare class DriaLocal extends DriaCommon { url: string; constructor(url?: string); /** A simple health-check. */ health(): Promise; /** A vector-based query. * @param vector query vector. * @param options query options: * - `topK`: number of results to return. * @template M type of the metadata, defaults to type provided to the client. * @returns an array of `topK` results with id, metadata and the relevancy score. * @example * const res = await dria.query<{about: string}>([0.1, 0.92, ..., 0.16]); * console.log(res[0].metadata.about); * * @deprecated local query is disabled right now */ private query; /** Fetch vectors with the given IDs. * @param ids an array of ids. * @template M type of the metadata, defaults to type provided to the client. * @returns an array of metadatas belonging to the given vector IDs. * @example * const res = await dria.fetch([0]) * console.log(res[0]) */ fetch(ids: number[]): Promise; /** * Insert a batch of vectors to your existing knowledge. * @param items batch of vectors with optional metadatas * @returns a string indicating success * @example * const batch = [ * {vector: [...], metadata: {}}, * {vector: [...], metadata: {foo: 'bar'}}, * // ... * ] * await dria.insertVectors(batch); */ insertVectors(items: BatchVectors): Promise; } export {};