UNPKG

react-native-qnn-llm

Version:
127 lines 3.62 kB
export declare enum SentenceCode { Complete = 0, Begin = 1, Continue = 2, End = 3, Abort = 4 } export declare const getHtpConfigFilePath: () => any; export interface SamplerConfig { 'version': number; 'seed': number; 'temp': number; 'top-k': number; 'top-p': number; 'greedy': boolean; } /** * Context config. * @see https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-100/json.html */ export interface ContextConfig { dialog: { version: number; type: 'basic'; context: { version: number; [key: string]: any; }; sampler: { version: number; [key: string]: any; }; tokenizer: { version: number; path: string; }; engine: { 'version': number; 'n-threads': number; 'backend': { type: 'QnnHtp' | 'QnnGenAiTransformer'; QnnHtp?: { 'use-mmap': boolean; [key: string]: any; }; QnnGenAiTransformer?: Record<string, any>; extensions?: string; }; 'model': { version: number; type: 'binary' | 'library'; binary?: { 'version': number; 'ctx-bins': string[]; }; library?: { 'version': number; 'model-bin': string; }; [key: string]: any; }; }; }; } export declare class Context { private _id; private constructor(); /** * Create a context from a config. * @param config - The config to create the context. * @returns The context. */ static create(config: ContextConfig): Promise<Context>; /** * Load a context from a bundle. * @param bundle_path - The path to the bundled model. * @param unpack_dir - The path to store the unpacked model. * @param n_threads - The number of threads to use. * @returns The context. */ static load({ bundle_path, unpack_dir, n_threads, }: { bundle_path: string; unpack_dir: string; n_threads?: number; }): Promise<Context>; /** * Process the prompt. * @param input - The prompt to process. */ process(input: string): Promise<void>; /** * Make a completion request. * @param input - The input to query. * @param callback - The callback to call when the response is received. * @returns Performance profile. */ query(input: string, callback: (response: string, sentenceCode: SentenceCode) => void): Promise<object>; /** * Set the stop words. * @param stopWords - The stop words to set. */ set_stop_words(stopWords?: string[]): Promise<void>; /** * Apply the sampler config. * @param config - The sampler config to apply. */ apply_sampler_config(config: Partial<SamplerConfig>): Promise<void>; /** * Save the session. * @param filename - The filename to save the session to. */ save_session(filename: string): Promise<void>; /** * Restore the session. * @param filename - The filename to restore the session from. */ restore_session(filename: string): Promise<void>; /** * Abort the completion. */ abort(): Promise<void>; /** * Release the context. */ release(): Promise<void>; } //# sourceMappingURL=index.d.ts.map