Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
"""Regression tests for the interactive multimodal tools toggle."""
|
|
|
|
import asyncio
|
|
import os
|
|
import sys
|
|
from unittest.mock import patch
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from agent import MultimodalAgent, MultimodalTools
|
|
from main import interactive_chat
|
|
|
|
|
|
def _run_commands(agent, *commands):
|
|
with patch("builtins.input", side_effect=commands):
|
|
asyncio.run(interactive_chat(agent))
|
|
|
|
|
|
def test_tools_on_configures_complete_tool_state():
|
|
agent = MultimodalAgent(enable_tools=False)
|
|
|
|
_run_commands(agent, "/tools on", "/quit")
|
|
|
|
assert agent.enable_multimodal_tools is True
|
|
assert isinstance(agent.tools, MultimodalTools)
|
|
assert {
|
|
definition["function"]["name"] for definition in agent.tool_definitions
|
|
} == {"analyze_image", "analyze_audio", "analyze_pdf"}
|
|
|
|
|
|
def test_tools_off_disables_tool_execution():
|
|
agent = MultimodalAgent(enable_tools=True)
|
|
|
|
_run_commands(agent, "/tools off", "/quit")
|
|
|
|
assert agent.enable_multimodal_tools is False
|
|
assert agent.tools is None
|