fix: isolate startup tools and preview dialogs
This commit is contained in:
@@ -246,6 +246,55 @@ class DifyLLMServiceTests(unittest.IsolatedAsyncioTestCase):
|
||||
|
||||
|
||||
class PromptBrainTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_startup_only_tool_is_not_registered_with_llm(self):
|
||||
startup_tool = RuntimeTool(
|
||||
id="opening_message",
|
||||
name="开场确认",
|
||||
function_name="show_message",
|
||||
type="client",
|
||||
)
|
||||
conversation_tool = RuntimeTool(
|
||||
id="lookup_order",
|
||||
name="查询订单",
|
||||
function_name="lookup_order",
|
||||
type="http",
|
||||
)
|
||||
cfg = AssistantConfig(
|
||||
type="prompt",
|
||||
tools=[startup_tool, conversation_tool],
|
||||
llm_tool_ids=[conversation_tool.id],
|
||||
startup={
|
||||
"actions": [
|
||||
{
|
||||
"id": "opening_message",
|
||||
"phase": "opening",
|
||||
"tool_id": startup_tool.id,
|
||||
"required": True,
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
brain = build_brain(cfg)
|
||||
llm = FakeLLM()
|
||||
visible_schemas = []
|
||||
|
||||
await brain.setup(
|
||||
cfg,
|
||||
BrainRuntime(
|
||||
context=LLMContext(messages=[]),
|
||||
llm=llm,
|
||||
queue_frame=noop_queue_frame,
|
||||
set_system_prompt=lambda _prompt: None,
|
||||
set_tools=visible_schemas.extend,
|
||||
call_end=FakeCallEnd(),
|
||||
),
|
||||
)
|
||||
|
||||
self.assertIn(startup_tool.id, brain._tool_by_id)
|
||||
self.assertNotIn(startup_tool.function_name, llm.functions)
|
||||
self.assertIn(conversation_tool.function_name, llm.functions)
|
||||
self.assertEqual(len(visible_schemas), 1)
|
||||
|
||||
async def test_preflight_runs_multiple_server_tools_in_order(self):
|
||||
tools = [
|
||||
RuntimeTool(
|
||||
|
||||
Reference in New Issue
Block a user