* Override createStream to handle GLM thinking-capable models. * These models have thinking enabled by default in the API, so we need to * explicitly send { type: "disabled" } when the user turns off reasoning.
( systemPrompt: string, messages: Anthropic.Messages.MessageParam[], metadata?: ApiHandlerCreateMessageMetadata, requestOptions?: OpenAI.RequestOptions, )
| 50 | * explicitly send { type: "disabled" } when the user turns off reasoning. |
| 51 | */ |
| 52 | protected override createStream( |
| 53 | systemPrompt: string, |
| 54 | messages: Anthropic.Messages.MessageParam[], |
| 55 | metadata?: ApiHandlerCreateMessageMetadata, |
| 56 | requestOptions?: OpenAI.RequestOptions, |
| 57 | ) { |
| 58 | const { id: modelId, info } = this.getModel() |
| 59 | |
| 60 | // Check if this is a model with thinking support (e.g. GLM-4.7, GLM-5) |
| 61 | const isThinkingModel = Array.isArray(info.supportsReasoningEffort) |
| 62 | |
| 63 | if (isThinkingModel) { |
| 64 | // Create the stream with our custom thinking parameter |
| 65 | return this.createStreamWithThinking(systemPrompt, messages, metadata) |
| 66 | } |
| 67 | |
| 68 | // For non-thinking models, use the default behavior |
| 69 | return super.createStream(systemPrompt, messages, metadata, requestOptions) |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Creates a stream with explicit thinking control for GLM thinking-capable models. |
no test coverage detected