前后端开发相关技巧
vscode操作快捷键
ctrl + p 在该项目中查找文件
ctrl + f 在代码中查找字段
linux指令
cd /mnt/d 进入到根目录 /mnt/d
cd ~/mnt/d 进入到用户目录 /home/warning02/mnt/d
rf -rm /name 递归、强制删除当前路径下的name文件夹
前端
nvm 指 nodejs运行环境
通过 nvm use 22,从而使用nodejs 22的版本
nvm npm pnpm 是什么关系,三者是怎样的安装顺序
nvm用于设置node js版本,npm是nodejs的包管理工具,pnpm 也是nodejs的包管理工具,pnpm与npm地位相同(实际使用pnpm多一些)
在前端的文件夹里,清空前端nodejs安装的包
rm -rf node_modules
rm -f pnpm-lock.yaml
rm -f package-lock.json
pnpm store prune # 清空全局缓存
rm -r 指递归删除文件夹,recursive递归
rm -f 指强制删除,不报错、不提示确认,force强制
在前端的文件夹里,执行pnpm install
pnpm install --frozen-lockfile --registry https://registry.npmmirror.com
pnpm-lock.yaml会锁定项目依赖的精确版本,确保不同环境下安装的依赖完全一致
pnpm run dev从而运行前端
后端
uv sync 类似于 pip install -r requirements.txt
使用uv时,pyproject.toml文件,类似于requirements.txt
如果tools工具有新使用别的包(比如PyPDF2),通过以下指令更新后端环境依赖
uv add PyPDF2
uv 通过 pip install来安装
pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
uv sync安装环境依赖
uv run app.py从而启动后端服务
后端使用 FastAPI修饰符定义的接口,可以通过后端开放的端口+ /docs进行访问(比如后端部署在http://0.0.0.0:8000/docs,可以通过访问http://0.0.0.0:8000/docs得到后端提供的接口)
F12网页调试窗口的使用
我的是联想笔记本,通过按Fn+F12,进入到网页调试窗口
前端页面点击接口对应的某些按钮,能够在网页调试窗口看到请求、响应信息
选择智能体,点击按钮开启对话,有关chat和session的请求与响应如下
bash
创建会话的请求为:
curl 'http://127.0.0.1:8000/agent/v1/session' \
-H 'Accept: */*' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,zh-CN;q=0.7,zh;q=0.6' \
-H 'Connection: keep-alive' \
-H 'Origin: http://localhost:5173' \
-H 'Referer: http://localhost:5173/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'Sec-Fetch-Storage-Access: active' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36' \
-H 'content-type: application/json' \
-H 'sec-ch-ua: "Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
--data-raw '{"agent_group_id":"common_research","agent_group_type":"local","develop_mode":false}'
response为:
{
"session_id": "sess-0113_095518-c88d6f",
"status": "success",
"created_at": 1768269318.134176,
"message": null,
"title": "untitled conversation"
}
进行会话聊天的请求为:
curl 'http://127.0.0.1:8000/agent/v1/sess-0113_095518-c88d6f/chat' \
-H 'Accept: */*' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,zh-CN;q=0.7,zh;q=0.6' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:5173' \
-H 'Referer: http://localhost:5173/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'Sec-Fetch-Storage-Access: active' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
--data-raw '{"input_type":"user_message","input_data":{"id":"usr_mkby1yc4wboiqeh","content":"北京周边旅游,一个人,1.15日出发,预算1000。"}}'
response为:
data: {
"interaction_id": "int-14c95b",
"event_id": "run-fafde74e-656c-4e1a-8d17-5e0e64945402",
"timestamp": 1768269591.7768538,
"ts_str": "2026-01-13 09:59:51",
"stream_id": "stream_response_001",
"stream_start": false,
"stream_end": false,
"is_end": false,
"end_reason": null,
"source": {
"type": "agent",
"agent_id": "root",
"agent_name": "通用研究",
"agent_type": "internal"
},
"event_type": "token",
"response_type": "token",
"data": {
"content": "我来",
"additional_kwargs": { },
"response_metadata": {
"agent_id": "root",
"agent_name": "通用研究"
},
"type": "AIMessageChunk",
"name": null,
"id": "run-fafde74e-656c-4e1a-8d17-5e0e64945402",
"example": false,
"tool_calls": [ ],
"invalid_tool_calls": [ ],
"usage_metadata": null,
"tool_call_chunks": [ ]
}
}
data: {
"interaction_id": "int-bc795d",
"event_id": "run-fafde74e-656c-4e1a-8d17-5e0e64945402",
"timestamp": 1768269591.7925339,
"ts_str": "2026-01-13 09:59:51",
"stream_id": "stream_response_001",
"stream_start": false,
"stream_end": false,
"is_end": false,
"end_reason": null,
"source": {
"type": "agent",
"agent_id": "root",
"agent_name": "通用研究",
"agent_type": "internal"
},
"event_type": "token",
"response_type": "token",
"data": {
"content": "帮您",
"additional_kwargs": { },
"response_metadata": {
"agent_id": "root",
"agent_name": "通用研究"
},
"type": "AIMessageChunk",
"name": null,
"id": "run-fafde74e-656c-4e1a-8d17-5e0e64945402",
"example": false,
"tool_calls": [ ],
"invalid_tool_calls": [ ],
"usage_metadata": null,
"tool_call_chunks": [ ]
}
}