返回提交历史
Modified
g4f/Provider/LegacyLMArena.py
+2
-4
Modified
g4f/providers/retry_provider.py
+4
-0
XFEstudio/gpt4free
Disable retries in LegacyLMArena
1f5bfe50
代码差异
2 个文件
+6
-4
@@ -421,6 +421,7 @@ class LegacyLMArena(AsyncGeneratorProvider, ProviderModelMixin):
421
421
top_p: float = 1,
422
422
conversation: JsonConversation = None,
423
423
return_conversation: bool = True,
424
max_retries: int = 1,
424
425
**kwargs
425
426
) -> AsyncResult:
426
427
async def read_response(response: StreamResponse):
@@ -487,7 +488,7 @@ class LegacyLMArena(AsyncGeneratorProvider, ProviderModelMixin):
487
488
488
489
if content and content != returned_data and content != '<span class="cursor"></span> ':
489
490
if "**NETWORK ERROR DUE TO HIGH TRAFFIC." in content:
490
raise ResponseError(data)
491
raise ResponseError(content)
491
492
if content.endswith("▌"):
492
493
content = content[:-1]
493
494
new_content = content
@@ -499,8 +500,6 @@ class LegacyLMArena(AsyncGeneratorProvider, ProviderModelMixin):
499
500
elif isinstance(output_data[1], str) and output_data[1]:
500
501
# Direct string content
501
502
content = output_data[1]
502
if "**NETWORK ERROR DUE TO HIGH TRAFFIC." in content:
503
raise ResponseError(data + " #2")
504
503
if content != returned_data:
505
504
if content.endswith("▌"):
506
505
content = content[:-1]
@@ -529,7 +528,6 @@ class LegacyLMArena(AsyncGeneratorProvider, ProviderModelMixin):
529
528
530
529
async with StreamSession(impersonate="chrome") as session:
531
530
# Add retry logic for better reliability
532
max_retries = 3
533
531
retry_count = 0
534
532
535
533
while retry_count < max_retries:
@@ -58,6 +58,8 @@ class IterListProvider(BaseRetryProvider):
58
58
alias = getattr(provider, "default_model", None)
59
59
if hasattr(provider, "model_aliases"):
60
60
alias = provider.model_aliases.get(model, model)
61
if isinstance(alias, list):
62
alias = random.choice(alias)
61
63
debug.log(f"Using provider: {provider.__name__} with model: {alias}")
62
64
yield ProviderInfo(**provider.get_dict(), model=alias)
63
65
extra_body = kwargs.copy()
@@ -104,6 +106,8 @@ class IterListProvider(BaseRetryProvider):
104
106
alias = getattr(provider, "default_model", None)
105
107
if hasattr(provider, "model_aliases"):
106
108
alias = provider.model_aliases.get(model, model)
109
if isinstance(alias, list):
110
alias = random.choice(alias)
107
111
debug.log(f"Using {provider.__name__} provider with model {alias}")
108
112
yield ProviderInfo(**provider.get_dict(), model=alias)
109
113
extra_body = kwargs.copy()