Skip to content

Commit

Permalink
Add consistent-ish retrying for all SUTs.
Browse files Browse the repository at this point in the history
  • Loading branch information
wpietri committed Nov 18, 2024
1 parent ef5e48d commit b325dc9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/anthropic/modelgauge/suts/anthropic_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, uid: str, model: str, api_key: AnthropicApiKey):
def _load_client(self) -> Anthropic:
return Anthropic(
api_key=self.api_key,
max_retries=10,
max_retries=7,
)

def translate_text_prompt(self, prompt: TextPrompt) -> AnthropicRequest:
Expand Down
2 changes: 1 addition & 1 deletion plugins/huggingface/modelgauge/suts/huggingface_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def translate_text_prompt(self, prompt: TextPrompt) -> HuggingFaceChatRequest:
),
)

@tenacity.retry(stop=stop_after_attempt(10), wait=wait_random_exponential())
@tenacity.retry(stop=stop_after_attempt(7), wait=wait_random_exponential())
def evaluate(self, request: HuggingFaceChatRequest) -> HuggingFaceResponse:
headers = {
"Accept": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion plugins/openai/modelgauge/suts/openai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self, uid: str, model: str, api_key: OpenAIApiKey, org_id: OpenAIOr
self.org_id = org_id.value

def _load_client(self) -> OpenAI:
return OpenAI(api_key=self.api_key, organization=self.org_id, max_retries=10)
return OpenAI(api_key=self.api_key, organization=self.org_id, max_retries=7)

def translate_text_prompt(self, prompt: TextPrompt) -> OpenAIChatRequest:
messages = [OpenAIChatMessage(content=prompt.text, role=_USER_ROLE)]
Expand Down
2 changes: 1 addition & 1 deletion src/modelgauge/suts/together_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _retrying_post(url, headers, json_payload):
"""HTTP Post with retry behavior."""
session = requests.Session()
retries = Retry(
total=10,
total=7,
backoff_factor=2,
status_forcelist=[
408, # Request Timeout
Expand Down

0 comments on commit b325dc9

Please sign in to comment.