/** * LLM API Module * * Main entry point for the LLM API functionality. * Provides initialization and specialized LLM functions: * - hazo_llm_text_text: Text input → Text output * - hazo_llm_image_text: Image input → Text output * - hazo_llm_text_image: Text input → Image output * - hazo_llm_image_image: Image input → Image output * - hazo_llm_document_text: Document input → Text output (PDF analysis) * - hazo_llm_text_image_text: Text → Image → Text (chained) * - hazo_llm_image_image_text: Images → Image → Text (chained) * * Database is auto-initialized on module import using config defaults. */ import type { LLMApiConfig, LLMApiClient, LLMResponse, LLMStreamResponse, TextTextParams, ImageTextParams, TextImageParams, ImageImageParams, DocumentTextParams, TextImageTextParams, ImageImageTextParams, PromptChainParams, PromptChainResponse, DynamicDataExtractParams, DynamicDataExtractResponse, EmbedParams, EmbedResponse, Logger, CostCapConfig } from './types.js'; import type { HazoConnect } from '../hazo_connect/types.js'; import type { ProviderName } from '../providers/types.js'; /** * Default structured logger used when no custom logger is provided. * Delegates to hazo_logs when available, auto-injects correlationId and env. */ export declare const default_logger: Logger; /** * Get the current logger instance * Returns the stored logger (set during initialization) or default logger * * @returns Current logger instance * * @example * ```typescript * import { get_logger } from 'hazo_llm_api/server'; * * const logger = get_logger(); * logger.info('My message'); * ``` */ export declare function get_logger(): Logger; /** * Set the logger instance * Called internally during initialization, but can also be called directly * * @param logger - Logger instance to use */ export declare function set_logger(logger: Logger): void; /** * Get the current hooks configuration * * @returns Current hooks configuration */ export declare function get_hooks(): import('./types.js').LLMHooks; /** * Set the hooks configuration * Called internally during initialization, but can also be called directly * * @param hooks - Hooks configuration to use */ export declare function set_hooks(hooks: import('./types.js').LLMHooks): void; /** * Get the current HazoConnect instance * Returns the stored HazoConnect (created during initialization) * * @returns Current HazoConnect instance or null if not initialized * * @example * ```typescript * import { get_hazo_connect } from 'hazo_llm_api/server'; * * const connect = get_hazo_connect(); * if (connect) { * const { success, data } = await connect.get_all(); * } * ``` */ export declare function get_hazo_connect(): HazoConnect | null; /** * Initialize the LLM API with the given configuration * Creates/connects to the database and prepares the client for use * * @param config - Configuration options for the LLM API (all fields optional) * @returns Initialized LLM API client * * @example * ```typescript * // Minimal initialization (uses defaults) * const api = await initialize_llm_api({}); * * // With custom logger * const api = await initialize_llm_api({ logger: myLogger }); * * // With custom database path * const api = await initialize_llm_api({ sqlite_path: '~/data/prompts.db' }); * ``` */ export declare function initialize_llm_api(config?: LLMApiConfig): Promise; /** * Check if database has been initialized (either auto or manual) * @returns true if database is ready for use */ export declare function is_database_ready(): boolean; /** * Wait for auto-initialization to complete * Useful if you need to ensure database is ready before operations */ export declare function ensure_database_ready(): Promise; /** * Text input → Text output * Standard text generation using LLM * * @param params - Text input parameters * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns LLM response with generated text * * @example * ```typescript * import { hazo_llm_text_text, LLM_PROVIDERS } from 'hazo_llm_api/server'; * * const response = await hazo_llm_text_text({ prompt: 'Hello' }, LLM_PROVIDERS.GEMINI); * ``` */ export declare function hazo_llm_text_text(params: TextTextParams, llm?: ProviderName): Promise; /** * Image input → Text output * Analyze an image and get text description * * @param params - Image input parameters * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns LLM response with text description */ export declare function hazo_llm_image_text(params: ImageTextParams, llm?: ProviderName): Promise; /** * Text input → Image output * Generate an image from text description * * @param params - Text input parameters for image generation * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns LLM response with generated image */ export declare function hazo_llm_text_image(params: TextImageParams, llm?: ProviderName): Promise; /** * Image input → Image output * Transform/edit an image based on instructions * * @param params - Image input parameters with transformation instructions * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns LLM response with transformed image */ export declare function hazo_llm_image_image(params: ImageImageParams, llm?: ProviderName): Promise; /** * Text → Image → Text (Chained) * Generate an image from prompt_image, then analyze it with prompt_text * * @param params - Parameters with two prompts: one for image gen, one for analysis * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns LLM response with generated image and analysis text */ export declare function hazo_llm_text_image_text(params: TextImageTextParams, llm?: ProviderName): Promise; /** * Images → Image → Text (Chained) * Chain multiple image transformations, then describe the final result * * @param params - Parameters with images, prompts, and description prompt * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns LLM response with final image and description text */ export declare function hazo_llm_image_image_text(params: ImageImageTextParams, llm?: ProviderName): Promise; /** * Document input → Text output * Analyze a document (PDF) and get text analysis/description * * @param params - Document input parameters * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns LLM response with text analysis * * @example * ```typescript * import { hazo_llm_document_text, LLM_PROVIDERS } from 'hazo_llm_api/server'; * * const response = await hazo_llm_document_text({ * prompt: 'Summarize this document', * document_b64: base64EncodedPdf, * document_mime_type: 'application/pdf', * }, LLM_PROVIDERS.GEMINI); * ``` */ export declare function hazo_llm_document_text(params: DocumentTextParams, llm?: ProviderName): Promise; /** * Execute a chain of prompts with dynamic value resolution * Each call can reference values from previous call results * * @param params - Chain parameters including call definitions * @param llm - Optional LLM provider name (uses primary LLM if not specified). Use LLM_PROVIDERS constants for type safety. * @returns Chain response with merged results and individual call outcomes * * @example * ```typescript * import { hazo_llm_prompt_chain } from 'hazo_llm_api/server'; * * const response = await hazo_llm_prompt_chain({ * chain_calls: [ * { * prompt_area: { match_type: 'direct', value: 'document' }, * prompt_key: { match_type: 'direct', value: 'initial_read' } * }, * { * prompt_area: { match_type: 'direct', value: 'document' }, * prompt_key: { match_type: 'direct', value: 'process_results' }, * local_1: { * match_type: 'call_chain', * value: 'call[0].tax_category', * variable_name: 'previous_category' * } * } * ] * }); * ``` */ export declare function hazo_llm_prompt_chain(params: PromptChainParams, llm?: ProviderName): Promise; /** * Execute a dynamic chain of LLM calls where each next prompt * is determined by JSON output from the current call using * the next_prompt database field with JSONPath extraction * * @param params - Dynamic extract parameters * @param llm - Optional LLM provider name (uses primary LLM if not specified) * @returns Dynamic extract response with merged results and step details * * @example * ```typescript * import { hazo_llm_dynamic_data_extract } from 'hazo_llm_api/server'; * * // Prompts in database: * // - "doc/classify" returns { document_type: "invoice" } * // with next_prompt: { static_prompt_area: "doc", dynamic_prompt_key: "$.document_type" } * // - "doc/invoice" returns { amount: 1500, vendor: "ACME" } * * const response = await hazo_llm_dynamic_data_extract({ * initial_prompt_area: 'doc', * initial_prompt_key: 'classify', * image_b64: '...', * image_mime_type: 'image/png' * }); * * // response.merged_result = { document_type: 'invoice', amount: 1500, vendor: 'ACME' } * ``` */ export declare function hazo_llm_dynamic_data_extract(params: DynamicDataExtractParams, llm?: ProviderName): Promise; /** * Generate vector embeddings for one or more text inputs. * Caches results in-memory (or via BYO Keyv) and deduplicates repeated texts in batches. * * @param params - Text string or array of strings to embed, plus optional model override * @returns EmbedResponse with vectors, dimensions, model, and cache flags * * @example * ```typescript * import { hazo_llm_embed } from 'hazo_llm_api/server'; * * const result = await hazo_llm_embed({ text: 'Hello world' }); * if (result.success) { * console.log(result.vectors?.[0]); // number[] * } * ``` */ export declare function hazo_llm_embed(params: EmbedParams, _llm?: string): Promise; /** * Text input → Text output (Streaming) * Generate text from a prompt with streaming response * * @param params - Text input parameters * @param llm - Optional LLM provider name (uses primary LLM if not specified) * @returns Async generator yielding text chunks * * @example * ```typescript * const stream = await hazo_llm_text_text_stream({ prompt: 'Tell me a story' }); * * for await (const chunk of stream) { * if (chunk.error) { * console.error(chunk.error); * break; * } * process.stdout.write(chunk.text); * if (chunk.done) break; * } * ``` */ export declare function hazo_llm_text_text_stream(params: TextTextParams, llm?: ProviderName): LLMStreamResponse; /** * Image input → Text output (Streaming) * Analyze an image and stream text description * * @param params - Image input parameters * @param llm - Optional LLM provider name (uses primary LLM if not specified) * @returns Async generator yielding text chunks */ export declare function hazo_llm_image_text_stream(params: ImageTextParams, llm?: ProviderName): LLMStreamResponse; /** * Check if the LLM API has been initialized * @returns true if initialized */ export declare function is_initialized(): boolean; /** * Get the current cascade configuration (from init or INI). * Returns null if no cascade config has been set. */ export declare function get_cascade_config(): import('../cascade/types.js').CascadeConfig | null; /** * Get the current cost cap configuration (set during initialize_llm_api). * Returns null if no cost cap config has been set. */ export declare function get_cost_cap_config(): CostCapConfig | null; /** * Get the current configuration (without sensitive logger) * @returns Current configuration or null if not initialized */ export declare function get_current_config(): Omit | null; export type { LLMApiConfig, LLMApiClient, LLMResponse, TextTextParams, ImageTextParams, TextImageParams, ImageImageParams, DocumentTextParams, TextImageTextParams, ImageImageTextParams, ChainImage, Logger, PromptVariable, PromptVariables, Base64Data, PromptTextMode, PromptRecord, CallLLMParams, GeminiGenerationConfig, GeminiApiGenerationConfig, ChainMatchType, ChainFieldDefinition, ChainCallDefinition, ChainCallResult, PromptChainParams, PromptChainResponse, DynamicDataExtractParams, DynamicDataExtractResponse, DynamicExtractStepResult, DynamicExtractStopReason, NextPromptConfig, NextPromptBranch, NextPromptCondition, NextPromptOperator, } from './types.js'; //# sourceMappingURL=index.d.ts.map