MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / completePrompt

Method completePrompt

src/api/providers/lite-llm.ts:314–345  ·  view source on GitHub ↗
(prompt: string)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

isGpt5Method · 0.95
fetchModelMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected