(prompt: string)
| 297 | } |
| 298 | |
| 299 | async completePrompt(prompt: string): Promise<string> { |
| 300 | try { |
| 301 | const isAzureAiInference = this._isAzureAiInference(this.options.openAiBaseUrl) |
| 302 | const model = this.getModel() |
| 303 | const modelInfo = model.info |
| 304 | |
| 305 | const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = { |
| 306 | model: model.id, |
| 307 | messages: [{ role: "user", content: prompt }], |
| 308 | } |
| 309 | |
| 310 | // Add max_tokens if needed |
| 311 | this.addMaxTokensIfNeeded(requestOptions, modelInfo) |
| 312 | |
| 313 | let response |
| 314 | try { |
| 315 | response = await this.client.chat.completions.create( |
| 316 | requestOptions, |
| 317 | isAzureAiInference ? { path: OPENAI_AZURE_AI_INFERENCE_PATH } : {}, |
| 318 | ) |
| 319 | } catch (error) { |
| 320 | throw handleOpenAIError(error, this.providerName) |
| 321 | } |
| 322 | |
| 323 | return response.choices?.[0]?.message.content || "" |
| 324 | } catch (error) { |
| 325 | if (error instanceof Error) { |
| 326 | throw new Error(`${this.providerName} completion error: ${error.message}`) |
| 327 | } |
| 328 | |
| 329 | throw error |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | private async *handleO3FamilyMessage( |
| 334 | modelId: string, |
nothing calls this directly
no test coverage detected