import type { FetchJsonOptions } from './browser/fetch'; export interface OllamaOutputUsage { input_tokens: number; output_tokens: number; } export interface OllamaToolCall { function: { name: string; arguments: Record; }; } export interface OllamaOutputMessage { role: 'assistant'; content: string; thinking?: string; tool_calls?: OllamaToolCall[]; } export interface OllamaOutputChatResponse { model: string; created_at: string; message: OllamaOutputMessage; done: true; done_reason: 'stop' | 'length' | 'load'; total_duration: number; load_duration: number; prompt_eval_duration: number; eval_duration: number; prompt_eval_count: number; eval_count: number; } export interface OllamaOutputChatStreamChunk { model: string; created_at: string; message: OllamaOutputMessage; done: false; } export type OllamaOutputResponse = OllamaOutputChatResponse | OllamaOutputChatStreamChunk; export interface OllamaInputMessage { role: 'user' | 'assistant' | 'system' | 'tool'; content: string; images?: string[]; tool_calls?: OllamaToolCall[]; tool_name?: string; } export interface OllamaInputOptions { temperature?: number; num_ctx?: number; top_k?: number; top_p?: number; min_p?: number; seed?: number; stop?: string[]; num_predict?: number; repeat_penalty?: number; presence_penalty?: number; frequency_penalty?: number; tfs_z?: number; mirostat?: number; mirostat_tau?: number; mirostat_eta?: number; num_gpu?: number; num_thread?: number; numa?: boolean; low_vram?: boolean; f16_kv?: boolean; vocab_only?: boolean; use_mmap?: boolean; use_mlock?: boolean; } export interface OllamaInputTool { type: 'function'; function: { name: string; description: string; parameters: { type: 'object'; properties: Record; required?: string[]; }; }; } export interface OllamaInputChatRequest { model: string; messages: OllamaInputMessage[]; stream?: boolean; think?: boolean; format?: 'json' | Record; options?: OllamaInputOptions; tools?: OllamaInputTool[]; keep_alive?: number | string; } /** Request options for the non-streaming helpers; `stream` is fixed by the helper itself. */ export type OllamaPromptRequest = Omit; /** Transport options forwarded to `fetchJson`, e.g. `timeout` and `signal`. */ export type OllamaFetchOptions = Pick; /** POSTs a chat request to an Ollama `/api/chat` endpoint. Throws `FetchError` on a non-2xx response. */ export declare function promptOllama(url: string, input: OllamaPromptRequest, options?: OllamaFetchOptions): Promise; /** Like `promptOllama`, but returns any thrown error instead of throwing. */ export declare function promptOllamaSafe(url: string, input: OllamaPromptRequest, options?: OllamaFetchOptions): Promise; /** POSTs a chat request with `format` defaulted to `'json'`, parsing `message.content` into `T`. */ export declare function promptOllamaJson(url: string, input: OllamaPromptRequest, options?: OllamaFetchOptions): Promise; /** Maps Ollama's `*_count` fields onto token usage. */ export declare function getOllamaUsage(res: OllamaOutputChatResponse): OllamaOutputUsage; /** Base generation settings for a single use case. */ export interface OllamaSettings { model: string; num_ctx: number; temperature: number; think: boolean; /** Max output tokens (Ollama num_predict). 0/undefined = unbounded. */ num_predict?: number; } /** Per-request overrides adjusting a base `OllamaSettings`. All optional. */ export interface OllamaSettingsOverride { model?: string; num_ctx?: number; temperature?: number; num_predict?: number; think?: boolean; } /** Merges base settings with optional overrides into the shape `promptOllama` wants. */ export declare function resolveOllamaSettings(base: OllamaSettings, override?: OllamaSettingsOverride): { model: string; think: boolean; options: OllamaInputOptions; }; /** Ollama's nanosecond durations and token counts, converted to UI-friendly units. */ export interface OllamaMeta { model: string; loadMs: number; promptEvalMs: number; evalMs: number; totalMs: number; promptTokens: number; outputTokens: number; tokensPerSec: number; rawInput: string; rawOutput: string; thinking?: string; } /** Converts an Ollama response's durations and token counts into an `OllamaMeta`. */ export declare function buildOllamaMeta(res: OllamaOutputChatResponse, rawInput: string): OllamaMeta; /** POSTs a chat request with `stream: true`, yielding each NDJSON chunk as it arrives. */ export declare function streamOllama(url: string, input: OllamaPromptRequest, options?: OllamaFetchOptions): AsyncGenerator; //# sourceMappingURL=ollama.d.ts.map