mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-02-19 17:10:03 +08:00
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
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user