mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
test: cover vision config temperature wiring\n\n- add regression tests for auxiliary.vision.temperature and timeout\n- add bugkill3r to AUTHOR_MAP for the salvaged commit
This commit is contained in:
parent
088bf9057f
commit
098d554aac
2 changed files with 61 additions and 0 deletions
|
|
@ -209,6 +209,7 @@ AUTHOR_MAP = {
|
||||||
"kagura.chen28@gmail.com": "kagura-agent",
|
"kagura.chen28@gmail.com": "kagura-agent",
|
||||||
"1342088860@qq.com": "youngDoo",
|
"1342088860@qq.com": "youngDoo",
|
||||||
"kamil@gwozdz.me": "kamil-gwozdz",
|
"kamil@gwozdz.me": "kamil-gwozdz",
|
||||||
|
"skmishra1991@gmail.com": "bugkill3r",
|
||||||
"karamusti912@gmail.com": "MustafaKara7",
|
"karamusti912@gmail.com": "MustafaKara7",
|
||||||
"kira@ariaki.me": "kira-ariaki",
|
"kira@ariaki.me": "kira-ariaki",
|
||||||
"knopki@duck.com": "knopki",
|
"knopki@duck.com": "knopki",
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,66 @@ class TestErrorLoggingExcInfo:
|
||||||
assert warning_records[0].exc_info is not None
|
assert warning_records[0].exc_info is not None
|
||||||
|
|
||||||
|
|
||||||
|
class TestVisionConfig:
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_vision_uses_configured_temperature_and_timeout(self, tmp_path):
|
||||||
|
img = tmp_path / "test.png"
|
||||||
|
img.write_bytes(b"\x89PNG\r\n\x1a\n" + b"\x00" * 8)
|
||||||
|
|
||||||
|
mock_response = MagicMock()
|
||||||
|
mock_choice = MagicMock()
|
||||||
|
mock_choice.message.content = "Configured image analysis"
|
||||||
|
mock_response.choices = [mock_choice]
|
||||||
|
|
||||||
|
with (
|
||||||
|
patch("hermes_cli.config.load_config", return_value={
|
||||||
|
"auxiliary": {"vision": {"temperature": 1, "timeout": 77}}
|
||||||
|
}),
|
||||||
|
patch(
|
||||||
|
"tools.vision_tools._image_to_base64_data_url",
|
||||||
|
return_value="data:image/png;base64,abc",
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"tools.vision_tools.async_call_llm",
|
||||||
|
new_callable=AsyncMock,
|
||||||
|
return_value=mock_response,
|
||||||
|
) as mock_llm,
|
||||||
|
):
|
||||||
|
result = json.loads(await vision_analyze_tool(str(img), "describe this", "test/model"))
|
||||||
|
|
||||||
|
assert result["success"] is True
|
||||||
|
assert mock_llm.await_args.kwargs["temperature"] == 1.0
|
||||||
|
assert mock_llm.await_args.kwargs["timeout"] == 77.0
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_vision_defaults_temperature_when_config_omits_it(self, tmp_path):
|
||||||
|
img = tmp_path / "test.png"
|
||||||
|
img.write_bytes(b"\x89PNG\r\n\x1a\n" + b"\x00" * 8)
|
||||||
|
|
||||||
|
mock_response = MagicMock()
|
||||||
|
mock_choice = MagicMock()
|
||||||
|
mock_choice.message.content = "Default image analysis"
|
||||||
|
mock_response.choices = [mock_choice]
|
||||||
|
|
||||||
|
with (
|
||||||
|
patch("hermes_cli.config.load_config", return_value={"auxiliary": {"vision": {}}}),
|
||||||
|
patch(
|
||||||
|
"tools.vision_tools._image_to_base64_data_url",
|
||||||
|
return_value="data:image/png;base64,abc",
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"tools.vision_tools.async_call_llm",
|
||||||
|
new_callable=AsyncMock,
|
||||||
|
return_value=mock_response,
|
||||||
|
) as mock_llm,
|
||||||
|
):
|
||||||
|
result = json.loads(await vision_analyze_tool(str(img), "describe this", "test/model"))
|
||||||
|
|
||||||
|
assert result["success"] is True
|
||||||
|
assert mock_llm.await_args.kwargs["temperature"] == 0.1
|
||||||
|
assert mock_llm.await_args.kwargs["timeout"] == 120.0
|
||||||
|
|
||||||
|
|
||||||
class TestVisionSafetyGuards:
|
class TestVisionSafetyGuards:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_local_non_image_file_rejected_before_llm_call(self, tmp_path):
|
async def test_local_non_image_file_rejected_before_llm_call(self, tmp_path):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue