250405-VSCode编辑launch.json实现Debug调试Open-WebUI

A. 最终效果

  • 根据__init__.py配置launch.json

  • 根据中utils/chat.pyform_data'messages' = [{'role': 'user', 'content': '唐老鸭'}],可以找到用户输入,进而通过关键词或模型调用的方式,对敏感问题进行特殊处理。

B. 文件配置

  • launch.json
json 复制代码
// {
//     // Use IntelliSense to learn about possible attributes.
//     // Hover to view descriptions of existing attributes.
//     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
//     "version": "0.2.0",
//     "configurations": [
//         {
//             "name": "Python Debugger: FastAPI",
//             "type": "debugpy",
//             "request": "launch",
//             "module": "uvicorn",
//             "args": [
//                 "main:app",
//                 "--reload"
//             ],
//             "jinja": true
//         }
//     ]
// }

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: FastAPI",
            "type": "debugpy",
            "request": "launch",
            "program": "${workspaceFolder}/__init__.py",  // 这里指定实际的脚本路径
            "args": [
                "serve",  // 修改为执行 `serve` 命令
                "--host", "0.0.0.0",
                "--port", "8080"
            ],
            "jinja": true,
            "justMyCode": false,  // 设置为 false 以调试第三方库代码
            "purpose": ["debug-in-terminal"] 
        }
    ],
}

C. 参考文献

相关推荐
阑梦清川13 小时前
vscode远程连接云服务器的初次尝试
vscode
Qiuner20 小时前
历劫波,明真我——Debug Commune
ai·开源·bug·debug·信息差·信息·交流
九河_1 天前
服务器在线安装插件失败/离线安装VSIX
vscode·extension·pylance
小池先生1 天前
用vscode查日志方便的搜索-复制所有匹配行功能
ide·vscode·编辑器
原小明2 天前
【Conda】Conda虚拟环境配置系统环境变量,Jupter可使用
vscode·python·jupyter·conda
慧都小项2 天前
Parasoft C/C++test如何将静态分析集成到VSCode中
vscode·静态分析·parasoft
kymix2 天前
vscode 远程管理docker时,提示权限不足无法获取容器列表问题
ide·vscode·docker
Gary Studio2 天前
VSCODE GDB调试
ide·vscode·编辑器
老程序员刘飞2 天前
vscode 连接 wsl
ide·vscode·编辑器
图亚Vanta2 天前
Python入门第一课:Python安装、VSCode/Pycharm配置
vscode·python·pycharm