Update mcp_client.py
Browse files- mcp_client.py +15 -2
mcp_client.py
CHANGED
|
@@ -27,6 +27,7 @@ class UniversalMCPClient:
|
|
| 27 |
self.current_provider = None
|
| 28 |
self.current_model = None
|
| 29 |
self.server_tools = {} # Cache for server tools
|
|
|
|
| 30 |
|
| 31 |
# Initialize HF Inference Client if token is available
|
| 32 |
if AppConfig.HF_TOKEN:
|
|
@@ -63,6 +64,13 @@ class UniversalMCPClient:
|
|
| 63 |
self.current_provider = provider_id
|
| 64 |
self.current_model = model_id
|
| 65 |
logger.info(f"🔧 Set provider: {provider_id}, model: {model_id}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
def get_model_endpoint(self) -> str:
|
| 68 |
"""Get the current model endpoint for API calls"""
|
|
@@ -241,11 +249,16 @@ class UniversalMCPClient:
|
|
| 241 |
"stream": kwargs.get("stream", False)
|
| 242 |
}
|
| 243 |
|
| 244 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
params.update(kwargs)
|
| 246 |
|
| 247 |
# Add reasoning effort if specified (GPT OSS feature)
|
| 248 |
-
reasoning_effort = kwargs.pop("reasoning_effort", AppConfig.DEFAULT_REASONING_EFFORT)
|
| 249 |
if reasoning_effort:
|
| 250 |
# For GPT OSS models, we can set reasoning in system prompt
|
| 251 |
system_message = None
|
|
|
|
| 27 |
self.current_provider = None
|
| 28 |
self.current_model = None
|
| 29 |
self.server_tools = {} # Cache for server tools
|
| 30 |
+
self.generation_params: Dict[str, Any] = {}
|
| 31 |
|
| 32 |
# Initialize HF Inference Client if token is available
|
| 33 |
if AppConfig.HF_TOKEN:
|
|
|
|
| 64 |
self.current_provider = provider_id
|
| 65 |
self.current_model = model_id
|
| 66 |
logger.info(f"🔧 Set provider: {provider_id}, model: {model_id}")
|
| 67 |
+
|
| 68 |
+
def set_generation_params(self, params: Dict[str, Any]):
|
| 69 |
+
"""Set generation parameters for chat completions (OpenAI-compatible)."""
|
| 70 |
+
# Clean None values to avoid sending invalid fields
|
| 71 |
+
cleaned = {k: v for k, v in params.items() if v is not None}
|
| 72 |
+
self.generation_params = cleaned
|
| 73 |
+
logger.info(f"🔧 Updated generation params: {list(self.generation_params.keys())}")
|
| 74 |
|
| 75 |
def get_model_endpoint(self) -> str:
|
| 76 |
"""Get the current model endpoint for API calls"""
|
|
|
|
| 249 |
"stream": kwargs.get("stream", False)
|
| 250 |
}
|
| 251 |
|
| 252 |
+
# Merge stored generation params (do not override explicitly provided kwargs later)
|
| 253 |
+
for k, v in self.generation_params.items():
|
| 254 |
+
if k not in ("model", "messages") and k not in params:
|
| 255 |
+
params[k] = v
|
| 256 |
+
|
| 257 |
+
# Add any remaining kwargs (highest precedence)
|
| 258 |
params.update(kwargs)
|
| 259 |
|
| 260 |
# Add reasoning effort if specified (GPT OSS feature)
|
| 261 |
+
reasoning_effort = kwargs.pop("reasoning_effort", self.generation_params.get("reasoning_effort", AppConfig.DEFAULT_REASONING_EFFORT))
|
| 262 |
if reasoning_effort:
|
| 263 |
# For GPT OSS models, we can set reasoning in system prompt
|
| 264 |
system_message = None
|