ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
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
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
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user