mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 20:54:59 +00:00
Merge branch 'main' into call-graph
This commit is contained in:
commit
106eab7a7a
2 changed files with 21 additions and 25 deletions
|
@ -2,10 +2,10 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
||||
import backoff
|
||||
import git
|
||||
import openai
|
||||
import requests
|
||||
|
@ -393,23 +393,19 @@ class Coder:
|
|||
|
||||
return prompts.added_files.format(fnames=", ".join(mentioned_rel_fnames))
|
||||
|
||||
@backoff.on_exception(
|
||||
backoff.expo,
|
||||
(RateLimitError, requests.exceptions.ConnectionError),
|
||||
max_tries=5,
|
||||
on_backoff=lambda details: print(f"Retry in {details['wait']} seconds."),
|
||||
)
|
||||
def send_with_retries(self, model, messages):
|
||||
while True:
|
||||
try:
|
||||
return openai.ChatCompletion.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
temperature=0,
|
||||
stream=True,
|
||||
)
|
||||
except RateLimitError as err:
|
||||
self.io.tool_error(f"RateLimitError: {err}")
|
||||
except requests.exceptions.ConnectionError as err:
|
||||
self.io.tool_error(f"ConnectionError: {err}")
|
||||
|
||||
retry_after = 1
|
||||
self.io.tool_error(f"Retry in {retry_after} seconds.")
|
||||
time.sleep(retry_after)
|
||||
return openai.ChatCompletion.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
temperature=0,
|
||||
stream=True,
|
||||
)
|
||||
|
||||
def send(self, messages, model=None, silent=False):
|
||||
if not model:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue