From 23fd6b8d2bdeccaf38ec101343e234d80e6c4e9b Mon Sep 17 00:00:00 2001 From: cowagent Date: Tue, 10 Feb 2026 10:52:05 +0800 Subject: [PATCH] fix: handle non-string model_type to prevent AttributeError When numeric model names (e.g., '1') are used with vLLM and configured in YAML without quotes, they are parsed as integers. This causes AttributeError when calling startswith() method. Changes: - Add type checking for model_type - Convert non-string model_type to string with warning log - Prevents crash when using custom numeric model names Fixes #2664 --- bridge/bridge.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bridge/bridge.py b/bridge/bridge.py index 1c42856..32d4b46 100644 --- a/bridge/bridge.py +++ b/bridge/bridge.py @@ -24,6 +24,13 @@ class Bridge(object): self.btype["chat"] = bot_type else: model_type = conf().get("model") or const.GPT_41_MINI + + # Ensure model_type is string to prevent AttributeError when using startswith() + # This handles cases where numeric model names (e.g., "1") are parsed as integers from YAML + if not isinstance(model_type, str): + logger.warning(f"[Bridge] model_type is not a string: {model_type} (type: {type(model_type).__name__}), converting to string") + model_type = str(model_type) + if model_type in ["text-davinci-003"]: self.btype["chat"] = const.OPEN_AI if conf().get("use_azure_chatgpt", False):