@@ -79,19 +79,19 @@ def transform_uni_config_to_model_config(self, config: UniConfig) -> dict[str, A
7979 if config .get ("temperature" ) is not None :
8080 glm_config ["temperature" ] = config ["temperature" ]
8181
82- # Convert thinking configuration
8382 if config .get ("thinking_level" ) is not None :
8483 thinking_config = self ._convert_thinking_level_to_config (config ["thinking_level" ])
8584 glm_config ["extra_body" ] = {"thinking" : thinking_config }
8685
87- # Convert tools to OpenAI's tool schema
8886 if config .get ("tools" ) is not None :
8987 glm_config ["tools" ] = [{"type" : "function" , "function" : tool } for tool in config ["tools" ]]
9088
91- # Convert tool_choice
9289 if config .get ("tool_choice" ) is not None :
9390 glm_config ["tool_choice" ] = self ._convert_tool_choice (config ["tool_choice" ])
9491
92+ if config .get ("prompt_caching" ) is not None and config ["prompt_caching" ] != PromptCaching .ENABLE :
93+ raise ValueError ("prompt_caching must be ENABLE for GLM-4.7." )
94+
9595 return glm_config
9696
9797 def transform_uni_message_to_model_input (self , messages : list [UniMessage ]) -> list [ChatCompletionMessageParam ]:
@@ -137,18 +137,16 @@ def transform_uni_message_to_model_input(self, messages: list[UniMessage]) -> li
137137 else :
138138 raise ValueError (f"Unknown item type: { item ['type' ]} " )
139139
140- # Build the message
141- message = {"role" : msg ["role" ], "content" : content_parts }
140+ if content_parts : # Content items may be empty for tool results
141+ message = {"role" : msg ["role" ], "content" : content_parts }
142142
143- # Add tool calls if present
144- if tool_calls :
145- message ["tool_calls" ] = tool_calls
143+ if tool_calls :
144+ message ["tool_calls" ] = tool_calls
146145
147- # Add reasoning content for thinking
148- if thinking :
149- message ["reasoning_content" ] = thinking
146+ if thinking :
147+ message ["reasoning_content" ] = thinking
150148
151- openai_messages .append (message )
149+ openai_messages .append (message )
152150
153151 return openai_messages
154152
0 commit comments