xiaozhi-esp32-server/test_codex.ipynb
2026-01-30 17:31:31 +08:00

249 lines
17 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "38e24e24",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32m260130 16:36:51\u001b[0m[0.8.11_00000000000000][\u001b[94mcore.providers.llm.codex.codex\u001b[0m]-\u001b[1mINFO\u001b[0m-\u001b[92mcodex_action\u001b[0m\n",
"{'kind': 'action', 'text': 'commandExecution cmd=\"C:\\\\\\\\WINDOWS\\\\\\\\System32\\\\\\\\WindowsPowerShell\\\\\\\\v1.0\\\\\\\\powershell.exe\" -Command \\'Get-Content .codex/skills/repo-bootstrap/SKILL.md\\'', 'phase': 'start'}\n",
"\u001b[32m260130 16:36:51\u001b[0m[0.8.11_00000000000000][\u001b[94mcore.providers.llm.codex.codex\u001b[0m]-\u001b[1mINFO\u001b[0m-\u001b[92mcodex_action\u001b[0m\n",
"{'kind': 'action', 'text': 'commandExecution cmd=\"C:\\\\\\\\WINDOWS\\\\\\\\System32\\\\\\\\WindowsPowerShell\\\\\\\\v1.0\\\\\\\\powershell.exe\" -Command \\'Get-Content .codex/skills/repo-bootstrap/SKILL.md\\'', 'phase': 'done'}\n",
"\u001b[32m260130 16:37:01\u001b[0m[0.8.11_00000000000000][\u001b[94mcore.providers.llm.codex.codex\u001b[0m]-\u001b[1mINFO\u001b[0m-\u001b[92mcodex_action\u001b[0m\n",
"{'kind': 'action', 'text': 'commandExecution cmd=\"C:\\\\\\\\WINDOWS\\\\\\\\System32\\\\\\\\WindowsPowerShell\\\\\\\\v1.0\\\\\\\\powershell.exe\" -Command Get-ChildItem', 'phase': 'start'}\n",
"\u001b[32m260130 16:37:01\u001b[0m[0.8.11_00000000000000][\u001b[94mcore.providers.llm.codex.codex\u001b[0m]-\u001b[1mINFO\u001b[0m-\u001b[92mcodex_action\u001b[0m\n",
"{'kind': 'action', 'text': 'commandExecution cmd=\"C:\\\\\\\\WINDOWS\\\\\\\\System32\\\\\\\\WindowsPowerShell\\\\\\\\v1.0\\\\\\\\powershell.exe\" -Command Get-ChildItem', 'phase': 'done'}\n",
"同\n",
"学\n",
"你好\n",
",我\n",
"是\n",
"小\n",
"智\n",
",\n",
"先\n",
"确认\n",
"一下\n",
"你\n",
"现在\n",
"做\n",
"的\n",
"实验\n",
"名称\n",
"是什么\n",
"、\n",
"进行\n",
"到\n",
"哪\n",
"一步\n",
"了\n",
"?\n",
"仓\n",
"库\n",
"根\n",
"目录\n",
"目前\n",
"包括\n",
" `.\n",
"cod\n",
"ex\n",
"`\n",
" \n",
"目录\n",
"(\n",
"存\n",
"放\n",
" Cod\n",
"ex\n",
" 技\n",
"能\n",
"与\n",
"配置\n",
",用\n",
"来\n",
"约\n",
"束\n",
"和\n",
"加载\n",
"化\n",
"学\n",
"助\n",
"教\n",
"行为\n",
")、\n",
"`\n",
"data\n",
"`\n",
" \n",
"目录\n",
"(\n",
"保存\n",
"教学\n",
"资料\n",
"等\n",
"实验\n",
"数据\n",
",\n",
"按\n",
"规定\n",
"默认\n",
"只\n",
"读\n",
")、\n",
"`\n",
"AG\n",
"ENTS\n",
".md\n",
":\n",
"1\n",
"`\n",
"(\n",
"详细\n",
"说明\n",
"助\n",
"教\n",
"身份\n",
"、\n",
"互动\n",
"和\n",
"安全\n",
"要求\n",
")、\n",
"`\n",
"cod\n",
"ex\n",
"_stream\n",
"_raw\n",
"_test\n",
"_session\n",
".log\n",
":\n",
"1\n",
"`\n",
"(\n",
"调\n",
"试\n",
"或\n",
"演\n",
"练\n",
"过程\n",
"的\n",
"原\n",
"始\n",
"日志\n",
",\n",
"便\n",
"于\n",
"完整\n",
"追\n",
"踪\n",
")、\n",
"`\n",
"cod\n",
"ex\n",
"_stream\n",
"_test\n",
"_session\n",
".log\n",
":\n",
"1\n",
"`\n",
"(\n",
"提\n",
"炼\n",
"后的\n",
"测试\n",
"日志\n",
",\n",
"快速\n",
"定位\n",
"最近\n",
"的\n",
"交\n",
"互\n",
"结果\n",
")。\n",
"需要\n",
"我\n",
"进一步\n",
"查看\n",
"或\n",
"整理\n",
"这些\n",
"内容\n",
"就\n",
"告诉\n",
"我\n",
"。\n",
"\u001b[32m260130 16:37:18\u001b[0m[0.8.11_00000000000000][\u001b[94mcore.providers.llm.codex.codex\u001b[0m]-\u001b[1mINFO\u001b[0m-\u001b[92mcodex_stream_turn_completed\u001b[0m\n"
]
}
],
"source": [
"import sys\n",
"sys.path.append(r\"C:\\Users\\yibinjiang\\Documents\\GitHub\\xiaozhi-esp32-server\\main\\xiaozhi-server\")\n",
"\n",
"from core.providers.llm.codex.codex import LLMProvider\n",
"\n",
"config = {\n",
" \"type\": \"codex\",\n",
" \"codex_bin\": \"codex.cmd\",\n",
" \"model_name\": \"gpt-5.1-codex\",\n",
" \"workspace\": r\"C:\\Users\\yibinjiang\\Documents\\GitHub\\codex_edu\",\n",
" \"auto_approve\": True,\n",
" \"network_access\": True,\n",
" \"effort\": \"high\",\n",
" \"emit_events\": True,\n",
" \"thinking_mode\": \"summary\",\n",
" \"show_actions\": True,\n",
" \"raw_stream_log\": True,\n",
" \"runtime_config\": {\"hide_agent_reasoning\": False},\n",
"}\n",
"config[\"summary\"] = \"detailed\"\n",
"\n",
"llm = LLMProvider(config)\n",
"\n",
"dialogue = [\n",
" {\"role\": \"user\", \"content\": \"请列出这个仓库顶层文件,并解释每个文件的作用。\"}\n",
"]\n",
"\n",
"for token in llm.response(session_id=\"test_session\", dialogue=dialogue, summary=\"detailed\"):\n",
" print(token)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b9c4f649",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "xiaozhi-esp32-server",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.19"
}
},
"nbformat": 4,
"nbformat_minor": 5
}