|  | 
| 31 | 31 | from ..logger.logger_utils import get_current_ts | 
| 32 | 32 | from ..runtime_logging import log_chat_completion, log_new_client, log_new_wrapper, logging_enabled | 
| 33 | 33 | from ..token_count_utils import count_token | 
| 34 |  | -from .client_utils import FormatterProtocol, logging_formatter | 
|  | 34 | +from .client_utils import FormatterProtocol, logging_formatter, merge_config_with_tools | 
| 35 | 35 | from .openai_utils import OAI_PRICE1K, get_key, is_valid_api_key | 
| 36 | 36 | 
 | 
| 37 | 37 | TOOL_ENABLED = False | 
| @@ -639,8 +639,11 @@ def _create_or_parse(*args, **kwargs): | 
| 639 | 639 |                     warnings.warn( | 
| 640 | 640 |                         f"The {params.get('model')} model does not support streaming. The stream will be set to False." | 
| 641 | 641 |                     ) | 
| 642 |  | -                if params.get("tools", False): | 
| 643 |  | -                    raise ModelToolNotSupportedError(params.get("model")) | 
|  | 642 | +                if "tools" in params: | 
|  | 643 | +                    if params["tools"]:  # If tools exist, raise as unsupported | 
|  | 644 | +                        raise ModelToolNotSupportedError(params.get("model")) | 
|  | 645 | +                    else: | 
|  | 646 | +                        params.pop("tools")  # Remove empty tools list | 
| 644 | 647 |                 self._process_reasoning_model_params(params) | 
| 645 | 648 |             params["stream"] = False | 
| 646 | 649 |             response = create_or_parse(**params) | 
| @@ -1083,7 +1086,7 @@ def create(self, **config: Any) -> ModelClient.ModelClientResponseProtocol: | 
| 1083 | 1086 |         for i in ordered_clients_indices: | 
| 1084 | 1087 |             # merge the input config with the i-th config in the config list | 
| 1085 | 1088 |             client_config = self._config_list[i] | 
| 1086 |  | -            full_config = {**config, **client_config, "tools": config.get("tools", []) + client_config.get("tools", [])} | 
|  | 1089 | +            full_config = merge_config_with_tools(config, client_config) | 
| 1087 | 1090 | 
 | 
| 1088 | 1091 |             # separate the config into create_config and extra_kwargs | 
| 1089 | 1092 |             create_config, extra_kwargs = self._separate_create_config(full_config) | 
|  | 
0 commit comments