feat(clients): ✨ Implement new model CRUD operations for Model Boss service
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
c723dda9cf
commit
3ae440a474
1 changed files with 18 additions and 0 deletions
|
|
@ -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<string> {
|
||||
let result = '';
|
||||
for await (const token of this.streamCompletion({
|
||||
messages,
|
||||
stream: true,
|
||||
model: options.model ?? this.config.get<string>('CHAT_MODEL', 'qwen3-4b'),
|
||||
max_tokens: options.max_tokens,
|
||||
temperature: options.temperature,
|
||||
})) {
|
||||
result += token;
|
||||
}
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
async *streamCompletion(request: CompletionRequest): AsyncGenerator<string, void, unknown> {
|
||||
const url = `${this.baseUrl}/v1/chat/completions`;
|
||||
const response = await fetch(url, {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue