Update mcp_client.py
Browse files- mcp_client.py +22 -17
mcp_client.py
CHANGED
|
@@ -257,23 +257,28 @@ class UniversalMCPClient:
|
|
| 257 |
# Add any remaining kwargs (highest precedence)
|
| 258 |
params.update(kwargs)
|
| 259 |
|
| 260 |
-
# Add reasoning effort
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
system_message
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
try:
|
| 279 |
logger.info(f"🤖 Calling {model_endpoint} via {self.current_provider}")
|
|
|
|
| 257 |
# Add any remaining kwargs (highest precedence)
|
| 258 |
params.update(kwargs)
|
| 259 |
|
| 260 |
+
# Add reasoning effort only for GPT-OSS models
|
| 261 |
+
if AppConfig.is_gpt_oss_model(self.current_model):
|
| 262 |
+
reasoning_effort = kwargs.pop("reasoning_effort", self.generation_params.get("reasoning_effort", AppConfig.DEFAULT_REASONING_EFFORT))
|
| 263 |
+
if reasoning_effort:
|
| 264 |
+
# For GPT OSS models, we can set reasoning in system prompt
|
| 265 |
+
system_message = None
|
| 266 |
+
for msg in messages:
|
| 267 |
+
if msg.get("role") == "system":
|
| 268 |
+
system_message = msg
|
| 269 |
+
break
|
| 270 |
+
|
| 271 |
+
if system_message:
|
| 272 |
+
system_message["content"] += f"\n\nReasoning: {reasoning_effort}"
|
| 273 |
+
else:
|
| 274 |
+
messages.insert(0, {
|
| 275 |
+
"role": "system",
|
| 276 |
+
"content": f"You are a helpful AI assistant. Reasoning: {reasoning_effort}"
|
| 277 |
+
})
|
| 278 |
+
else:
|
| 279 |
+
# Ensure reasoning_effort is not sent in params for non-GPT-OSS
|
| 280 |
+
if "reasoning_effort" in params:
|
| 281 |
+
params.pop("reasoning_effort", None)
|
| 282 |
|
| 283 |
try:
|
| 284 |
logger.info(f"🤖 Calling {model_endpoint} via {self.current_provider}")
|