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

相关推荐
青花瓷2 小时前
VSCode中结合DeepSeek使用Cline插件的感受
ide·人工智能·vscode·大模型·编辑器·deepseek
向日葵.3 小时前
vscode使用方式
ide·vscode·编辑器
还是鼠鼠6 小时前
Node.js自定义中间件
javascript·vscode·中间件·node.js·json·express
暗碳11 小时前
vscode c语言环境配置
c语言·ide·vscode
╰つ゛木槿19 小时前
使用VSCode编写C#程序
ide·vscode·c#
花花鱼1 天前
vscode中的【粘滞滚动】的基本概念和作用,关闭了以后如何开启
ide·vscode·编辑器
blakeyi1 天前
vscode保存自动刷新cocos creator编辑器
ide·vscode·cocos creator·热更新
周博洋K1 天前
VScode 玩 MCP的server
ide·vscode·编辑器
rainFFrain1 天前
日志与策略模式
linux·运维·vscode·策略模式