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]
models: enh delay settings for concurrent queries
Kilian Lieret5f522b0501af
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.pyindex 43509d59..646f13c3 100644--- a/sweagent/agent/models.py+++ b/sweagent/agent/models.py@@ -87,9 +87,8 @@ class GenericAPIModelConfig(PydanticBaseModel):"""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. Actual delay is random between 0 and `delay`.+ """Minimum delay before querying (this can help to avoid overusing the API if sharing+ it with other people)."""fallbacks: list[dict[str, Any]] = []@@ -158,6 +157,9 @@ class GlobalStats(PydanticBaseModel):total_cost: float = 0"""Cumulative cost for all instances so far"""+ last_query_timestamp: float = 0+ """Timestamp of the last query. Currently only used with API models."""+GLOBAL_STATS = GlobalStats()"""This object tracks usage numbers (costs etc.) across all instances.@@ -535,7 +537,11 @@ class LiteLLMModel(AbstractModel):return output_dictdef query(self, history: History) -> dict:- time.sleep(random.uniform(0, self.args.delay))+ elapsed_time = time.time() - GLOBAL_STATS.last_query_timestamp+ if elapsed_time < self.args.delay:+ time.sleep(self.args.delay - elapsed_time)+ with GLOBAL_STATS_LOCK:+ GLOBAL_STATS.last_query_timestamp = time.time()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),