import{createOpenAICompatible as e}from"@ai-sdk/openai-compatible";import{generateText as t,streamText as n}from"ai";var r=class{#e;#t;constructor(t){this.#t=t,this.#e=e({name:t.name,baseURL:t.baseUrl,apiKey:t.apiKey,headers:t.headers})}#n(e){if(e)return{promptTokens:e.inputTokens??0,completionTokens:e.outputTokens??0,totalTokens:e.totalTokens??0}}async generate(e){let n={model:this.#e(e.model||``),temperature:e.temperature,maxOutputTokens:e.maxTokens,maxRetries:2,abortSignal:e.abortSignal},r=await t(e.messages&&e.messages.length>0?{...n,messages:e.messages}:{...n,prompt:e.prompt||``,system:e.system});return{content:r.text,model:e.model||``,provider:this.#t.name,usage:this.#n(r.usage),finishReason:r.finishReason}}async stream(e){let t={model:this.#e(e.model||``),temperature:e.temperature,maxOutputTokens:e.maxTokens,maxRetries:2,abortSignal:e.abortSignal};return await n(e.messages&&e.messages.length>0?{...t,messages:e.messages}:{...t,prompt:e.prompt||``,system:e.system})}getProviderName(){return this.#t.name}};export{r as t};