( systemPrompt: string, messages: Anthropic.Messages.MessageParam[], metadata?: ApiHandlerCreateMessageMetadata, requestOptions?: OpenAI.RequestOptions, )
| 68 | } |
| 69 | |
| 70 | protected createStream( |
| 71 | systemPrompt: string, |
| 72 | messages: Anthropic.Messages.MessageParam[], |
| 73 | metadata?: ApiHandlerCreateMessageMetadata, |
| 74 | requestOptions?: OpenAI.RequestOptions, |
| 75 | ) { |
| 76 | const { id: model, info } = this.getModel() |
| 77 | |
| 78 | // Centralized cap: clamp to 20% of the context window (unless provider-specific exceptions apply) |
| 79 | const max_tokens = |
| 80 | getModelMaxOutputTokens({ |
| 81 | modelId: model, |
| 82 | model: info, |
| 83 | settings: this.options, |
| 84 | format: "openai", |
| 85 | }) ?? undefined |
| 86 | |
| 87 | const temperature = this.options.modelTemperature ?? info.defaultTemperature ?? this.defaultTemperature |
| 88 | |
| 89 | const params: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = { |
| 90 | model, |
| 91 | max_tokens, |
| 92 | temperature, |
| 93 | messages: [{ role: "system", content: systemPrompt }, ...convertToOpenAiMessages(messages)], |
| 94 | stream: true, |
| 95 | stream_options: { include_usage: true }, |
| 96 | tools: this.convertToolsForOpenAI(metadata?.tools), |
| 97 | tool_choice: metadata?.tool_choice, |
| 98 | parallel_tool_calls: metadata?.parallelToolCalls ?? true, |
| 99 | } |
| 100 | |
| 101 | // Add thinking parameter if reasoning is enabled and model supports it |
| 102 | if (this.options.enableReasoningEffort && info.supportsReasoningBinary) { |
| 103 | ;(params as any).thinking = { type: "enabled" } |
| 104 | } |
| 105 | |
| 106 | try { |
| 107 | return this.client.chat.completions.create(params, requestOptions) |
| 108 | } catch (error) { |
| 109 | throw handleOpenAIError(error, this.providerName) |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | override async *createMessage( |
| 114 | systemPrompt: string, |
nothing calls this directly
no test coverage detected