From bc7610cddaa5b2da5394aed25d409d3ee87a6cd8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 1 Jul 2023 07:38:24 -0700 Subject: [PATCH] retry on Timeout --- aider/coders/base_coder.py | 10 ++++++++-- docs/benchmarks.md | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 9f8e1b770..f6830cc50 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -12,7 +12,7 @@ import backoff import git import openai import requests -from openai.error import APIError, RateLimitError, ServiceUnavailableError +from openai.error import APIError, RateLimitError, ServiceUnavailableError, Timeout from rich.console import Console, Text from rich.live import Live from rich.markdown import Markdown @@ -565,7 +565,13 @@ class Coder: @backoff.on_exception( backoff.expo, - (APIError, ServiceUnavailableError, RateLimitError, requests.exceptions.ConnectionError), + ( + Timeout, + APIError, + ServiceUnavailableError, + RateLimitError, + requests.exceptions.ConnectionError, + ), max_tries=5, on_backoff=lambda details: print(f"Retry in {details['wait']} seconds."), ) diff --git a/docs/benchmarks.md b/docs/benchmarks.md index 1f6bd7e69..dd49e4091 100644 --- a/docs/benchmarks.md +++ b/docs/benchmarks.md @@ -9,7 +9,7 @@ You can use aider to ask GPT to add features, write tests or make other changes improvements to your code. Having a reliable way for GPT to edit -local source code files is a critical component of this functionality. +local source code files is a critical to providing this functionality. Making code editing more reliable often involves changing and experimenting with the "edit format" that aider uses. @@ -40,8 +40,8 @@ I ran this code editing benchmark on almost all the ChatGPT models, using a variety of edit formats. This produced some interesting results: - - Asking GPT to just return an updated copy of the whole file in a normal fenced code block is by far the most reliable and effective edit format. This is true across all GPT-3.5 and GPT-4 models. - - Using the new function calling API is worse than the above whole file method, for all models. GPT writes worse code and frequently mangles this output format, even though OpenAI introduced the function calling API to make structured output formatting more reliable. This was a big surprise. + - Asking GPT to return an updated copy of the whole file in a normal markdown fenced code block is by far the most reliable and effective edit format. This is true across all GPT-3.5 and GPT-4 models. + - Using the new function calling API is worse than the above whole file method, for all models. GPT writes worse code and frequently mangles this output format, even though the function calling API was introduced to make structured outputs more reliable. This was a big surprise. - The new June (`0613`) versions of `gpt-3.5-turbo` are worse at code editing than the older February (`0301`) version. This was unexpected. - The GPT-4 models are much better at code editing than the GPT-3.5 models, as expected.