mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(anthropic): revert inline vision, add hermes model flow, wire vision aux
Feedback fixes:
1. Revert _convert_vision_content — vision is handled by the vision_analyze
tool, not by converting image blocks inline in conversation messages.
Removed the function and its tests.
2. Add Anthropic to 'hermes model' (cmd_model in main.py):
- Added to provider_labels dict
- Added to providers selection list
- Added _model_flow_anthropic() with Claude Code credential auto-detection,
API key prompting, and model selection from catalog.
3. Wire up Anthropic as a vision-capable auxiliary provider:
- Added _try_anthropic() to auxiliary_client.py using claude-sonnet-4
as the vision model (Claude natively supports multimodal)
- Added to the get_vision_auxiliary_client() auto-detection chain
(after OpenRouter/Nous, before Codex/custom)
Cache tracking note: the Anthropic cache metrics branch in run_agent.py
(cache_read_input_tokens / cache_creation_input_tokens) is in the correct
place — it's response-level parsing, same location as the existing
OpenRouter cache tracking. auxiliary_client.py has no cache tracking.
This commit is contained in:
@@ -413,43 +413,6 @@ class TestNormalizeResponse:
|
||||
assert len(msg.tool_calls) == 1
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Vision content conversion
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestVisionContentConversion:
|
||||
def test_base64_image(self):
|
||||
from agent.anthropic_adapter import _convert_vision_content
|
||||
|
||||
content = [
|
||||
{"type": "text", "text": "What's in this image?"},
|
||||
{"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBOR"}},
|
||||
]
|
||||
result = _convert_vision_content(content)
|
||||
assert result[0] == {"type": "text", "text": "What's in this image?"}
|
||||
assert result[1]["type"] == "image"
|
||||
assert result[1]["source"]["type"] == "base64"
|
||||
assert result[1]["source"]["media_type"] == "image/png"
|
||||
assert result[1]["source"]["data"] == "iVBOR"
|
||||
|
||||
def test_url_image(self):
|
||||
from agent.anthropic_adapter import _convert_vision_content
|
||||
|
||||
content = [
|
||||
{"type": "image_url", "image_url": {"url": "https://example.com/img.png"}},
|
||||
]
|
||||
result = _convert_vision_content(content)
|
||||
assert result[0]["type"] == "image"
|
||||
assert result[0]["source"]["type"] == "url"
|
||||
assert result[0]["source"]["url"] == "https://example.com/img.png"
|
||||
|
||||
def test_passthrough_non_list(self):
|
||||
from agent.anthropic_adapter import _convert_vision_content
|
||||
|
||||
assert _convert_vision_content("plain text") == "plain text"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Role alternation
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user