import * as smoltalk from "smoltalk";
import { DEFAULT_EMBEDDING_MODEL } from "../constants.js";
export class SmoltalkClient {
    async text(config) {
        return smoltalk.text({ ...this.toSmolConfig(config), stream: false });
    }
    async *textStream(config) {
        yield* smoltalk.text({ ...this.toSmolConfig(config), stream: true });
    }
    async embed(input, config) {
        // Default to an embedding model — chat model defaults (e.g.
        // gpt-4o-mini) would be rejected by smoltalk.embed.
        return smoltalk.embed(input, {
            model: DEFAULT_EMBEDDING_MODEL,
            ...config,
        });
    }
    toSmolConfig(config) {
        const { messages, tools, responseFormat, abortSignal, model, apiKey, maxTokens, temperature, provider, thinking, reasoningEffort, metadata, } = config;
        return {
            ...metadata,
            messages, tools, responseFormat, abortSignal,
            model, maxTokens, temperature, provider, thinking, reasoningEffort,
            openAiApiKey: apiKey,
        };
    }
}
