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

相关推荐
天空'之城12 小时前
VS Code Git 工作树:告别频繁切分支,实现多分支并行开发实战方案
git·vscode·版本控制·嵌入式开发·开发效率·worktree·多分支管理
AM艾玛12 小时前
Flutter 环境搭建实录
vscode·flutter
程序员爱德华14 小时前
VSCode git/gerrit解冲突
git·vscode·gerrit
蓝冰凌2 天前
vscode 用户级 settings.json
ide·vscode·json
九九落2 天前
VSCode AI编程完全指南:从环境搭建到实战应用
ide·vscode·ai编程
开发者联盟league2 天前
vscode接入deepseek
vscode·deepseek
小小放舟、2 天前
VS Code Code Runner 中文乱码修复与 IDEA 风格输出配置
vscode·python·code runner
开发者联盟league2 天前
vscode接入deepseek实现inline suggestions
vscode·编辑器
知福致福3 天前
vscode连接远程服务器登录codex插件一直卡在gpt图标页,不跳转浏览器登录
服务器·vscode·gpt
A小调的码农3 天前
OPENOCD+MSYS+VSCODE:从“灯不亮“到“终于亮了“
ide·vscode·stm32·单片机·编辑器