Normalize product data prompt formatting
This commit is contained in:
@@ -10,6 +10,7 @@ from pathlib import Path
|
||||
from src.agent_tools import build_tool_context, default_tool_registry, execute_tool
|
||||
from src.agent_types import AgentRuntimeConfig
|
||||
from src.data_agent_records import (
|
||||
build_planning_prompt,
|
||||
confirm_generation_goal,
|
||||
confirm_generation_plan,
|
||||
export_dataset_records,
|
||||
@@ -262,6 +263,47 @@ target: Agent(tag='地图导航')
|
||||
self.assertIn('[function]', rows[0]['newPrompt'])
|
||||
self.assertTrue(rows[0]['newPrompt'].endswith('<|im_start|>assistant\n'))
|
||||
|
||||
def test_build_planning_prompt_matches_standard_chat_template(self) -> None:
|
||||
records = normalize_dataset_draft(
|
||||
'''
|
||||
# dataset_label: 地图导航边界数据
|
||||
### case: 多轮顺路停车场
|
||||
用户: 帮我查一下最近的停车场
|
||||
小爱: 最近的停车场离你27米
|
||||
用户: 帮我找一个最顺路的停车场
|
||||
target: Agent(tag='地图导航')
|
||||
'''.strip(),
|
||||
batch_id='demo',
|
||||
base_timestamp=1_755_567_930_500,
|
||||
timestamp_step_ms=60_000,
|
||||
)['records']
|
||||
records[0]['context'] = {'location': '', 'rag': ''}
|
||||
|
||||
prompt = build_planning_prompt(records[0], system_prompt='你是小爱同学,中文智能语音助手。\n')
|
||||
|
||||
self.assertEqual(
|
||||
prompt,
|
||||
'<|im_start|>system\n'
|
||||
'你是小爱同学,中文智能语音助手。<|im_end|>\n'
|
||||
'<|im_start|>user\n'
|
||||
'请参考用户的[当前query]、[对话历史]、[知识注入]、[系统状态]识别出[当前query]的[function]结果,[function]是python的code形式。\n'
|
||||
'[知识注入]\n'
|
||||
'{\n'
|
||||
'"location": "",\n'
|
||||
'"rag": ""\n'
|
||||
'}\n'
|
||||
'[系统状态]\n'
|
||||
'{}\n'
|
||||
'[对话历史]\n'
|
||||
'用户: 帮我查一下最近的停车场\n'
|
||||
'小爱: 最近的停车场离你27米\n'
|
||||
'[当前query]\n'
|
||||
'用户: 帮我找一个最顺路的停车场\n'
|
||||
'[function]\n'
|
||||
'<|im_end|>\n'
|
||||
'<|im_start|>assistant\n',
|
||||
)
|
||||
|
||||
def test_export_planning_eval_csv_writes_file(self) -> None:
|
||||
records = normalize_dataset_draft(
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user