diff --git a/aider/args.py b/aider/args.py index 88fd68536..e20d99db4 100644 --- a/aider/args.py +++ b/aider/args.py @@ -216,7 +216,7 @@ def get_parser(default_config_files, git_root): ) group.add_argument( "--timeout", - type=int, + type=float, default=None, help="Timeout in seconds for API calls (default: None)", ) diff --git a/aider/main.py b/aider/main.py index ead3c127f..f88b8268b 100644 --- a/aider/main.py +++ b/aider/main.py @@ -509,8 +509,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F litellm._lazy_module.aclient_session = httpx.AsyncClient(verify=False) if args.timeout: - litellm._load_litellm() - litellm._lazy_module.request_timeout = args.timeout + models.request_timeout = args.timeout if args.dark_mode: args.user_input_color = "#32FF32" diff --git a/aider/models.py b/aider/models.py index 2160547f7..de3a91b0a 100644 --- a/aider/models.py +++ b/aider/models.py @@ -22,6 +22,8 @@ from aider.sendchat import ensure_alternating_roles, sanity_check_messages RETRY_TIMEOUT = 60 +request_timeout = 600 + DEFAULT_MODEL_NAME = "gpt-4o" ANTHROPIC_BETA_HEADER = "prompt-caching-2024-07-31,pdfs-2024-09-25" @@ -599,7 +601,7 @@ class Model(ModelSettings): # dump(kwargs) hash_object = hashlib.sha1(key) - res = litellm.completion(**kwargs) + res = litellm.completion(timeout=request_timeout, **kwargs) return hash_object, res def remove_reasoning_content(self, res):