yym68686 commited on
Commit
478e740
·
1 Parent(s): 1b4cad3

🐛 Bug: The bug where the provider's name, which is purely numeric, was not converted to a string has been fixed.

Browse files
Files changed (2) hide show
  1. main.py +1 -1
  2. utils.py +9 -1
main.py CHANGED
@@ -799,7 +799,7 @@ def lottery_scheduling(weights):
799
  def get_provider_rules(model_rule, config, request_model):
800
  provider_rules = []
801
  if model_rule == "all":
802
- # 如���模型名为 all,则返回所有模型
803
  for provider in config["providers"]:
804
  model_dict = get_model_dict(provider)
805
  for model in model_dict.keys():
 
799
  def get_provider_rules(model_rule, config, request_model):
800
  provider_rules = []
801
  if model_rule == "all":
802
+ # 如模型名为 all,则返回所有模型
803
  for provider in config["providers"]:
804
  model_dict = get_model_dict(provider)
805
  for model in model_dict.keys():
utils.py CHANGED
@@ -250,6 +250,9 @@ def update_config(config_data, use_config_url=False):
250
  if provider.get('cf_account_id'):
251
  provider['base_url'] = 'https://api.cloudflare.com/'
252
 
 
 
 
253
  provider_api = provider.get('api', None)
254
  if provider_api:
255
  if isinstance(provider_api, int):
@@ -440,7 +443,12 @@ async def error_handling_wrapper(generator):
440
  try:
441
  async for item in generator:
442
  yield ensure_string(item)
443
- except (httpx.ReadError, asyncio.CancelledError, httpx.RemoteProtocolError) as e:
 
 
 
 
 
444
  logger.error(f"Network error in new_generator: {e}")
445
  raise
446
 
 
250
  if provider.get('cf_account_id'):
251
  provider['base_url'] = 'https://api.cloudflare.com/'
252
 
253
+ if isinstance(provider['provider'], int):
254
+ provider['provider'] = str(provider['provider'])
255
+
256
  provider_api = provider.get('api', None)
257
  if provider_api:
258
  if isinstance(provider_api, int):
 
443
  try:
444
  async for item in generator:
445
  yield ensure_string(item)
446
+ except asyncio.CancelledError:
447
+ # 客户端断开连接是正常行为,不需要记录错误日志
448
+ logger.debug("Stream cancelled by client")
449
+ return
450
+ except (httpx.ReadError, httpx.RemoteProtocolError) as e:
451
+ # 只记录真正的网络错误
452
  logger.error(f"Network error in new_generator: {e}")
453
  raise
454