Skip to content

Commit

Permalink
🐛 Bug: The bug where the provider's name, which is purely numeric, wa…
Browse files Browse the repository at this point in the history
…s not converted to a string has been fixed.
  • Loading branch information
yym68686 committed Nov 7, 2024
1 parent 1b4cad3 commit 478e740
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def lottery_scheduling(weights):
def get_provider_rules(model_rule, config, request_model):
provider_rules = []
if model_rule == "all":
# 如���模型名为 all,则返回所有模型
# 如模型名为 all,则返回所有模型
for provider in config["providers"]:
model_dict = get_model_dict(provider)
for model in model_dict.keys():
Expand Down
10 changes: 9 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ def update_config(config_data, use_config_url=False):
if provider.get('cf_account_id'):
provider['base_url'] = 'https://api.cloudflare.com/'

if isinstance(provider['provider'], int):
provider['provider'] = str(provider['provider'])

provider_api = provider.get('api', None)
if provider_api:
if isinstance(provider_api, int):
Expand Down Expand Up @@ -440,7 +443,12 @@ async def new_generator():
try:
async for item in generator:
yield ensure_string(item)
except (httpx.ReadError, asyncio.CancelledError, httpx.RemoteProtocolError) as e:
except asyncio.CancelledError:
# 客户端断开连接是正常行为,不需要记录错误日志
logger.debug("Stream cancelled by client")
return
except (httpx.ReadError, httpx.RemoteProtocolError) as e:
# 只记录真正的网络错误
logger.error(f"Network error in new_generator: {e}")
raise

Expand Down

0 comments on commit 478e740

Please sign in to comment.