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. 参考文献

相关推荐
on_pluto_16 小时前
【debug】vscode 和 codex 不兼容问题
ide·人工智能·vscode·编辑器
阿鹿.16 小时前
Claude code
vscode
pan_junbiao20 小时前
Visual Studio Code的应用:笔记
vscode
一杯原谅绿茶21 小时前
VSCode的Eclipse插件-编译Eclipse项目
ide·vscode·eclipse
迷路爸爸1802 天前
cursor资源管理器修改为与vscode一样的纵向布局
ide·vscode·编辑器
星羽XingYu2 天前
esp32 vscode clangd 无法索引库函数解决方案
ide·vscode·编辑器
Dontla2 天前
VSCode Python扩展自动加载.env环境变量机制(Python插件)python.terminal.useEnvFile
ide·vscode·python
平头某2 天前
DSH:Agent 的 VSCode 时刻?
ide·vscode·编辑器
Dontla2 天前
VSCode打开关闭控制台面板快捷键ctrl+`(terminal快捷键、vscode控制台快捷键)
ide·vscode·编辑器
徽京人3 天前
VS Code 接入Esp 32步骤
vscode·单片机·嵌入式硬件