mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
fix(title): honor configured auxiliary timeout
This commit is contained in:
parent
5178b3f056
commit
5126902f1d
2 changed files with 32 additions and 1 deletions
|
|
@ -51,7 +51,7 @@ def _title_language() -> str:
|
|||
def generate_title(
|
||||
user_message: str,
|
||||
assistant_response: str,
|
||||
timeout: float = 30.0,
|
||||
timeout: Optional[float] = None,
|
||||
failure_callback: Optional[FailureCallback] = None,
|
||||
main_runtime: dict = None,
|
||||
) -> Optional[str]:
|
||||
|
|
|
|||
|
|
@ -59,6 +59,37 @@ class TestGenerateTitle:
|
|||
with patch("hermes_cli.config.load_config", side_effect=RuntimeError("bad config")):
|
||||
assert _title_language() == ""
|
||||
|
||||
def test_default_timeout_delegates_to_auxiliary_config(self):
|
||||
captured_kwargs = {}
|
||||
|
||||
def mock_call_llm(**kwargs):
|
||||
captured_kwargs.update(kwargs)
|
||||
resp = MagicMock()
|
||||
resp.choices = [MagicMock()]
|
||||
resp.choices[0].message.content = "Configured Timeout"
|
||||
return resp
|
||||
|
||||
with patch("agent.title_generator.call_llm", side_effect=mock_call_llm):
|
||||
assert generate_title("question", "answer") == "Configured Timeout"
|
||||
|
||||
assert captured_kwargs["task"] == "title_generation"
|
||||
assert captured_kwargs["timeout"] is None
|
||||
|
||||
def test_explicit_timeout_still_overrides_config(self):
|
||||
captured_kwargs = {}
|
||||
|
||||
def mock_call_llm(**kwargs):
|
||||
captured_kwargs.update(kwargs)
|
||||
resp = MagicMock()
|
||||
resp.choices = [MagicMock()]
|
||||
resp.choices[0].message.content = "Explicit Timeout"
|
||||
return resp
|
||||
|
||||
with patch("agent.title_generator.call_llm", side_effect=mock_call_llm):
|
||||
assert generate_title("question", "answer", timeout=123.0) == "Explicit Timeout"
|
||||
|
||||
assert captured_kwargs["timeout"] == 123.0
|
||||
|
||||
def test_strips_quotes(self):
|
||||
mock_response = MagicMock()
|
||||
mock_response.choices = [MagicMock()]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue