fix: support AI commands in media captions

This commit is contained in:
Azimkin
2026-09-14 14:35:48 +02:00
parent 40e7930e60
commit c6b93c9aa8
6 changed files with 62 additions and 10 deletions

View File

@@ -167,6 +167,7 @@ class AgentContextTests(unittest.IsolatedAsyncioTestCase):
chat=SimpleNamespace(id=99),
from_user=SimpleNamespace(id=42),
reply_to_message=None,
photo=SimpleNamespace(file_size=100),
)
account = SimpleNamespace(
me=SimpleNamespace(id=7, full_name="Owner", username="owner"),
@@ -184,6 +185,7 @@ class AgentContextTests(unittest.IsolatedAsyncioTestCase):
)
agent = MagicMock()
agent.create_session.return_value = session
attached_media = MagicMock()
with (
patch("app.agentic.OpenAIBasedLLM") as llm_class,
@@ -191,6 +193,10 @@ class AgentContextTests(unittest.IsolatedAsyncioTestCase):
patch("app.agentic.BraveSearchTools") as brave_tools,
patch("app.agentic.WebPageTools") as web_page_tools,
patch("app.agentic._build_context_messages", AsyncMock(return_value=[])),
patch(
"app.agentic._download_message_media",
AsyncMock(return_value=[attached_media]),
),
):
brave_tools.return_value.tools.return_value = []
web_page_tools.return_value.tools.return_value = []
@@ -210,6 +216,7 @@ class AgentContextTests(unittest.IsolatedAsyncioTestCase):
model="ds-model",
)
self.assertTrue(aggregator_class.call_args.kwargs["thinking"])
session.run.assert_awaited_once_with("prompt", media=[attached_media])
brave_tools.assert_called_once_with(api_key="brave-key", timeout_seconds=10.0)
web_page_tools.assert_called_once_with(timeout_seconds=45.0, max_chars=60_000)
result.handle.close()