Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Feat(models): delay option for litellm

Kilian Lieret70f1cbd94d6d
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.py
index 52081cf4..891d383e 100644
--- a/sweagent/agent/models.py
+++ b/sweagent/agent/models.py
@@ -80,7 +80,15 @@ class GenericAPIModelConfig(PydanticBaseModel):
"""
retry: RetryConfig = RetryConfig()
- """Retry configuration"""
+ """Retry configuration: How often to retry after a failure (e.g., from a rate limit)
+ etc.
+ """
+
+ delay: float = 0.0
+ """Delay before querying (this can help to avoid overusing the API if sharing
+ it with other people). In most other cases you probably want to rely on the
+ `retry` configuration.
+ """
# pydantic
model_config = ConfigDict(extra="forbid")
@@ -490,6 +498,7 @@ class LiteLLMModel(AbstractModel):
return output_dict
def query(self, history: History) -> dict:
+ time.sleep(self.args.delay)
for attempt in Retrying(
stop=stop_after_attempt(self.args.retry.retries),
wait=wait_random_exponential(min=self.args.retry.min_wait, max=self.args.retry.max_wait),