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

A. 最终效果

  • 根据__init__.py配置launch.json

  • 根据中utils/chat.py中form_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. 参考文献

相关推荐
摇滚侠3 小时前
使用 VSCode 开发 Java 经验分享
java·经验分享·vscode
哎写bug的程序员2 天前
关于VSCode上gcc,gdb的安装配置问题
ide·vscode·编辑器
旺旺的碎冰冰~2 天前
VScode解决终端输出中文乱码问题
ide·vscode·编辑器
jason.zeng@15022072 天前
使用vscode+flutter开发android程序(入门)
android·vscode·flutter
golang学习记3 天前
最新版VS Code开发Spring Boot项目保姆级教程
java·spring boot·vscode·后端
2501_915918414 天前
在 Xcode 中运行和调试单元测试的完整指南
ide·vscode·macos·ios·单元测试·个人开发·xcode
面壁的熊猫4 天前
工作和学习中的高效工具
vscode
不爱吃鱼的蔓热莓5 天前
释放VSCode插件占用系统盘垃圾
ide·vscode·编辑器
2501_915106325 天前
iOS开发之Xcode常用调试技巧总结
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
bing_feilong5 天前
vscode: ssh Got bad result from install script
ide·vscode·ssh