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

相关推荐
周小天..1 小时前
cmake+vscode+cuda的使用(windows)
ide·vscode·编辑器
YanaDH1 小时前
前端开发新机环境部署(带链接)
git·vscode·npm·node.js
纯.Pure_Jin(g)2 小时前
【Python练习五】Python 正则与网络爬虫实战:专项练习(2道经典练习带你巩固基础——看完包会)
开发语言·vscode·python
Hello World . .3 小时前
Linux:线程(thread)
linux·开发语言·vscode
淘矿人19 小时前
[特殊字符] 别再手动写提示词了!Claude Skills 10分钟入门,效率暴涨200%,Token狂省78%
人工智能·vscode·python·pycharm·github·文心一言·ai编程
纯.Pure_Jin(g)1 天前
寒假Python班作业(三)
开发语言·vscode·python
嵌入小生0072 天前
进程的基本概念\相关命令\创建\调度\状态及相关函数接口---软件编程---嵌入式(Linux)
linux·vscode·vim·嵌入式·进程·fork·软件编程
Brian-coder2 天前
从零开始:本地开发部署智能体系统(显存≥8GB)
pytorch·vscode·python·深度学习·chatgpt
纯.Pure_Jin(g)2 天前
寒假Python班作业(一)
开发语言·vscode·python
secondyoung2 天前
Git使用:常用操作对应指令
开发语言·经验分享·git·vscode·github·visual studio code·visual studio