(prompt: string)
| 312 | } |
| 313 | |
| 314 | async completePrompt(prompt: string): Promise<string> { |
| 315 | const { id: modelId, info } = await this.fetchModel() |
| 316 | |
| 317 | // Check if this is a GPT-5 model that requires max_completion_tokens instead of max_tokens |
| 318 | const isGPT5Model = this.isGpt5(modelId) |
| 319 | |
| 320 | try { |
| 321 | const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = { |
| 322 | model: modelId, |
| 323 | messages: [{ role: "user", content: prompt }], |
| 324 | } |
| 325 | |
| 326 | if (this.supportsTemperature(modelId)) { |
| 327 | requestOptions.temperature = this.options.modelTemperature ?? 0 |
| 328 | } |
| 329 | |
| 330 | // GPT-5 models require max_completion_tokens instead of the deprecated max_tokens parameter |
| 331 | if (isGPT5Model && info.maxTokens) { |
| 332 | requestOptions.max_completion_tokens = info.maxTokens |
| 333 | } else if (info.maxTokens) { |
| 334 | requestOptions.max_tokens = info.maxTokens |
| 335 | } |
| 336 | |
| 337 | const response = await this.client.chat.completions.create(requestOptions) |
| 338 | return response.choices[0]?.message.content || "" |
| 339 | } catch (error) { |
| 340 | if (error instanceof Error) { |
| 341 | throw new Error(`LiteLLM completion error: ${error.message}`) |
| 342 | } |
| 343 | throw error |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | // LiteLLM usage may include an extra field for Anthropic use cases. |
nothing calls this directly
no test coverage detected