refactor: Change timeout handling to use float type and global request_timeout

This commit is contained in:
Paul Gauthier 2025-02-06 11:36:15 -08:00 committed by Paul Gauthier (aider)
parent ae6fc41ca9
commit 39855f4d2b
3 changed files with 5 additions and 4 deletions

View file

@ -216,7 +216,7 @@ def get_parser(default_config_files, git_root):
) )
group.add_argument( group.add_argument(
"--timeout", "--timeout",
type=int, type=float,
default=None, default=None,
help="Timeout in seconds for API calls (default: None)", help="Timeout in seconds for API calls (default: None)",
) )

View file

@ -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) litellm._lazy_module.aclient_session = httpx.AsyncClient(verify=False)
if args.timeout: if args.timeout:
litellm._load_litellm() models.request_timeout = args.timeout
litellm._lazy_module.request_timeout = args.timeout
if args.dark_mode: if args.dark_mode:
args.user_input_color = "#32FF32" args.user_input_color = "#32FF32"

View file

@ -22,6 +22,8 @@ from aider.sendchat import ensure_alternating_roles, sanity_check_messages
RETRY_TIMEOUT = 60 RETRY_TIMEOUT = 60
request_timeout = 600
DEFAULT_MODEL_NAME = "gpt-4o" DEFAULT_MODEL_NAME = "gpt-4o"
ANTHROPIC_BETA_HEADER = "prompt-caching-2024-07-31,pdfs-2024-09-25" ANTHROPIC_BETA_HEADER = "prompt-caching-2024-07-31,pdfs-2024-09-25"
@ -599,7 +601,7 @@ class Model(ModelSettings):
# dump(kwargs) # dump(kwargs)
hash_object = hashlib.sha1(key) hash_object = hashlib.sha1(key)
res = litellm.completion(**kwargs) res = litellm.completion(timeout=request_timeout, **kwargs)
return hash_object, res return hash_object, res
def remove_reasoning_content(self, res): def remove_reasoning_content(self, res):