@prexo/ai-chat-sdk
Version:
AI Chat SDK for building AI chat applications with Context and History
52 lines (47 loc) • 1.88 kB
TypeScript
import { GetContextClientParams, BaseVectorContext, ResetOptions, VectorPayload, AddContextPayload, SaveOperationResult } from './types.js';
import { Index } from '@upstash/vector';
import '@upstash/redis';
import 'ai';
declare const getContextClient: (params?: GetContextClientParams) => BaseVectorContext | undefined;
declare class VectorDB {
private index;
constructor(index: Index);
reset(options?: ResetOptions): Promise<void>;
delete({ ids, namespace }: {
ids: string[];
namespace?: string;
}): Promise<void>;
/**
* A method that allows you to query the vector database with plain text.
* It takes care of the text-to-embedding conversion by itself.
* Additionally, it lets consumers pass various options to tweak the output.
*/
retrieve<TMetadata>({ question, similarityThreshold, topK, namespace, contextFilter, queryMode, }: VectorPayload): Promise<{
data: string;
id: string;
metadata: TMetadata;
}[]>;
/**
* A method that allows you to add various data types into a vector database.
* It supports plain text, embeddings, PDF, HTML, Text file and CSV. Additionally, it handles text-splitting for CSV, PDF and Text file.
*/
save(input: AddContextPayload): Promise<SaveOperationResult>;
}
type ExtVectorConfig = {
url: string;
token: string;
};
declare class ExtVector {
private vectorDB;
private namespace;
constructor(config: ExtVectorConfig, namespace: string);
addContext(input: AddContextPayload): Promise<SaveOperationResult>;
removeContext(ids: string[]): Promise<void>;
getContext<TMetadata>(payload: Omit<VectorPayload, "namespace">): Promise<{
data: string;
id: string;
metadata: TMetadata;
}[]>;
resetContext(): Promise<void>;
}
export { ExtVector, VectorDB, getContextClient };