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

Method createStream

src/api/providers/zai.ts:52–70  ·  view source on GitHub ↗

* 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,
	)

Source from the content-addressed store, hash-verified

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.

Callers 1

createMessageFunction · 0.80

Calls 2

getModelMethod · 0.65

Tested by

no test coverage detected