diff --git a/@applications/api/src/clients/model-boss.client.ts b/@applications/api/src/clients/model-boss.client.ts index 49a4dfb..9f0ec59 100644 --- a/@applications/api/src/clients/model-boss.client.ts +++ b/@applications/api/src/clients/model-boss.client.ts @@ -106,6 +106,24 @@ export class ModelBossClient { return { pcm, durationMs: data.durationMs }; } + /** Non-streaming completion — collects the full response and returns it. */ + async complete( + messages: ChatMessage[], + options: { model?: string; max_tokens?: number; temperature?: number } = {}, + ): Promise { + let result = ''; + for await (const token of this.streamCompletion({ + messages, + stream: true, + model: options.model ?? this.config.get('CHAT_MODEL', 'qwen3-4b'), + max_tokens: options.max_tokens, + temperature: options.temperature, + })) { + result += token; + } + return result.trim(); + } + async *streamCompletion(request: CompletionRequest): AsyncGenerator { const url = `${this.baseUrl}/v1/chat/completions`; const response = await fetch(url, {