From 2518901e6e4e3578fdda3b64c3b2ec76d682931f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Mon, 24 Mar 2025 23:48:00 +0530 Subject: [PATCH] feat: Support seed parameter (#7441) --- README.md | 1 + openhands/core/config/llm_config.py | 2 ++ openhands/llm/async_llm.py | 1 + openhands/llm/llm.py | 1 + 4 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 282f0712e5..df88aa233a 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ docker pull docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik docker run -it --rm --pull=always \ -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.29-nikolaik \ -e LOG_ALL_EVENTS=true \ + -e LLM_SEED=42 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.openhands-state:/.openhands-state \ -p 3000:3000 \ diff --git a/openhands/core/config/llm_config.py b/openhands/core/config/llm_config.py index 060592e725..ae6742cacd 100644 --- a/openhands/core/config/llm_config.py +++ b/openhands/core/config/llm_config.py @@ -43,6 +43,7 @@ class LLMConfig(BaseModel): custom_tokenizer: A custom tokenizer to use for token counting. native_tool_calling: Whether to use native tool calling if supported by the model. Can be True, False, or not set. reasoning_effort: The effort to put into reasoning. This is a string that can be one of 'low', 'medium', 'high', or 'none'. Exclusive for o1 models. + seed: The seed to use for the LLM. """ model: str = Field(default='claude-3-7-sonnet-20250219') @@ -82,6 +83,7 @@ class LLMConfig(BaseModel): custom_tokenizer: str | None = Field(default=None) native_tool_calling: bool | None = Field(default=None) reasoning_effort: str | None = Field(default='high') + seed: int | None = Field(default=None) model_config = {'extra': 'forbid'} diff --git a/openhands/llm/async_llm.py b/openhands/llm/async_llm.py index 805240c2b1..a9a9224a9b 100644 --- a/openhands/llm/async_llm.py +++ b/openhands/llm/async_llm.py @@ -34,6 +34,7 @@ class AsyncLLM(LLM): temperature=self.config.temperature, top_p=self.config.top_p, drop_params=self.config.drop_params, + seed=self.config.seed, ) async_completion_unwrapped = self._async_completion diff --git a/openhands/llm/llm.py b/openhands/llm/llm.py index bfc0a22fea..98a736da89 100644 --- a/openhands/llm/llm.py +++ b/openhands/llm/llm.py @@ -165,6 +165,7 @@ class LLM(RetryMixin, DebugMixin): timeout=self.config.timeout, top_p=self.config.top_p, drop_params=self.config.drop_params, + seed=self.config.seed, **kwargs, )