一、发现问题
安装 open-webui 的报错 api.openai.com 不通,因为 open-webui 最新版和以前的不一样了,所以网上的很多资料都用不了,经过一番摸索,找到解决办法
另外如果发现浏览器打开之后白屏,则是因为后台正在配置,等大概5分钟就好了
- 我的环境
ubuntu 22.04
python 3.11
open-webui:0.5.20
- 安装open-webui 报错
Connection error: Cannot connect to host api.openai.com:443 ssl:default [None]
二、解决问题
有两个办法
- 修改文件
修改文件:
/usr/local/lib/python3.11/dist-packages/open_webui/utils/models.py
async def get_all_base_models(request: Request, user: UserModel = None):function_models = []openai_models = []ollama_models = []# if request.app.state.config.ENABLE_OPENAI_API:# openai_models = await openai.get_all_models(request, user=user)# openai_models = openai_models["data"]if request.app.state.config.ENABLE_OLLAMA_API:ollama_models = await ollama.get_all_models(request, user=user)ollama_models = [{"id": model["model"],"name": model["name"],"object": "model","created": int(time.time()),"owned_by": "ollama","ollama": model,}for model in ollama_models["models"]]function_models = await get_function_models(request)models = function_models + openai_models + ollama_modelsreturn models
代码说明:
这个 if 判断是用来检测 openia 的开关的,可以直接注释掉,或者 将开关关闭
- 禁用开关
export ENABLE_OPENAI_API=false
三、参考地址
https://github.com/open-webui/open-webui/discussions/3702