/** * LLM polishing module — OpenAI-compatible chat completions. * * Ported from src-tauri/src/llm/openai.rs * * Supports any OpenAI-compatible provider — endpoint is fully specified by the * caller, nothing is hard-coded here. * * Common base URLs: * OpenAI → https://api.openai.com/v1 * DeepSeek → https://api.deepseek.com * Groq → https://api.groq.com/openai/v1 * Gemini → https://generativelanguage.googleapis.com/v1beta/openai * Ollama → http://localhost:11434/v1 * OpenRouter → https://openrouter.ai/api/v1 * GLM → https://open.bigmodel.cn/api/paas/v4 * SiliconFlow → https://api.siliconflow.cn/v1 * * Features: * - Custom vocabulary injection into system prompt * - Streaming mode via onChunk callback * - GLM thinking-mode handling (reasoning_content fallback) * - Translation support * * Requires Node.js >= 18 (native fetch). */ import { type BuildPromptOptions } from "./prompt.js"; export type { AppType } from "./prompt.js"; export interface LlmConfig { /** OpenAI-compatible API base URL (e.g. 'https://api.openai.com/v1') */ baseUrl: string; /** Provider API key */ apiKey: string; /** Model name (e.g. 'gpt-4o', 'deepseek-chat', 'glm-4-flash') */ model: string; /** Maximum tokens to generate. Default: 4096 */ maxTokens?: number; /** * Sampling temperature (0–2). Default: 0.1 * * Kept low by default because polishing is a deterministic cleanup task — * the model should not "create" content, only reformat what was spoken. */ temperature?: number; /** Request timeout in milliseconds. Default: 60_000 */ timeoutMs?: number; } export interface PolishOptions extends BuildPromptOptions { /** * Called with each streamed token chunk. * When provided, the request runs in streaming mode (SSE). */ onChunk?: (chunk: string) => void; } /** * Polish raw transcript text using an OpenAI-compatible LLM. * * @param rawText - Raw transcript from STT * @param config - LLM provider configuration * @param options - Polishing options (vocabulary, translation, streaming, etc.) * @returns Polished text * * @example * // Non-streaming * const polished = await polishText(transcript, { * provider: 'openai', * apiKey: process.env.OPENAI_API_KEY!, * model: 'gpt-4o-mini', * }, { * vocabulary: ['Tauri'], * appType: 'chat', * }); * * @example * // Streaming * const polished = await polishText(transcript, config, { * onChunk: (chunk) => process.stdout.write(chunk), * }); */ export declare function polishText(rawText: string, config: LlmConfig, options?: PolishOptions): Promise; //# sourceMappingURL=llm.d.ts.map