序
本文主要研究一下如何使用OpenWebUI+deepseek構(gòu)建本地AI知識庫
步驟
拉取open-webui鏡像
docker pull ghcr.io/open-webui/open-webui:main
docker啟動
docker run -d -p 3000:8080 \
-e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
ghcr.io/open-webui/open-webui:main
執(zhí)行完之后等一會(大概要三四分鐘)啟動起來了訪問http://localhost:3000/旺入,注冊管理員賬號丹鸿,注冊完要等一會(估計要七八分鐘)頁面才出來
可以-v ./open-webui-data:/app/backend/data
來掛載數(shù)據(jù)
看日志是有報錯
ERROR [open_webui.routers.openai] Connection error: Cannot connect to host api.openai.com:443 ssl:default [Connect call failed ('108.160.165.173', 443)]
ERROR [open_webui.routers.openai] Connection error: Cannot connect to host api.openai.com:443 ssl:default [Connect call failed ('108.160.165.173', 443)]
ERROR [open_webui.routers.openai] Connection error: Cannot connect to host api.openai.com:443 ssl:default [Connect call failed ('108.160.165.173', 443)]
ERROR [open_webui.routers.openai] Connection error: Cannot connect to host api.openai.com:443 ssl:default [Connect call failed ('108.160.165.173', 443)]
INFO [open_webui.routers.ollama] get_all_models()
INFO [open_webui.routers.ollama] get_all_models()
INFO [open_webui.routers.ollama] get_all_models()
INFO [open_webui.routers.ollama] get_all_models()
登錄之后,設(shè)置 --> 管理員設(shè)置 --> 外部鏈接,禁用掉OpenAI API计福,記得保存
開啟聯(lián)網(wǎng)搜索
在設(shè)置 --> 管理員設(shè)置 --> 聯(lián)網(wǎng)搜索 --> 啟用,然后下拉選擇厦酬,這里選擇tavily融撞,可以去https://app.tavily.com/注冊然后獲取api key,最后點擊保存就可以了
截屏2025-02-17 09.38.16.png
示例:今天日期是多少指煎,看open-webui輸出
INFO [open_webui.routers.retrieval] save_docs_to_vector_db: document 在線時鐘:當(dāng)前時間, 世界時鐘 :: 美國 (United States) - 當(dāng)前時間, 今天日期, ????¤?????—¥??? ???¨???3, 現(xiàn)在北京時間 在線標準北京時間校對 web-search-d8b3e7117d85062f511572e3004ad60997448e8ed9e9b7e3bac5
INFO [open_webui.routers.retrieval] adding to collection web-search-d8b3e7117d85062f511572e3004ad60997448e8ed9e9b7e3bac5
/pytorch/third_party/ideep/mkl-dnn/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h, 451: Can't read MIDR_EL1 sysfs entry
INFO [open_webui.retrieval.utils] query_doc:result [['7ee3e76c-7804-4eb7-8dbb-7ca27b0a54ca', 'ef5b7e5c-8a7e-4220-800e-9390e9808034', '97e23c2b-43f7-457a-a086-8b264acb90e8']] [[{'description': '世界時間 - 美國 (United States) - 現(xiàn)在世界各地是什么時間蹋偏?', 'embedding_config': '{"engine": "", "model": "sentence-transformers/all-MiniLM-L6-v2"}', 'language': 'zh', 'source': 'https://24timezones.com/美國/時間', 'start_index': 3508, 'title': '世界時鐘 :: 美國 (United States) - 當(dāng)前時間'}, {'description': '根據(jù)您所在的位置找出今天是什麼日期。了解格式為 mm-dd-yyyy 的確切數(shù)字日期至壤。', 'embedding_config': '{"engine": "", "model": "sentence-transformers/all-MiniLM-L6-v2"}', 'language': 'zh', 'source': 'https://thetimecalculator.org/zh/today-date', 'start_index': 1773, 'title': '今天日期'}, {'description': '世界時間 - 美國 (United States) - 現(xiàn)在世界各地是什么時間威始?', 'embedding_config': '{"engine": "", "model": "sentence-transformers/all-MiniLM-L6-v2"}', 'language': 'zh', 'source': 'https://24timezones.com/美國/時間', 'start_index': 2775, 'title': '世界時鐘 :: 美國 (United States) - 當(dāng)前時間'}]]
結(jié)果如下:
根據(jù)上下文中的信息,今天的日期是 星期一, 二月 17, 2025 [source_id=1]像街。
截屏2025-02-17 10.35.27.png
知識庫管理
- 設(shè)置 --> 管理員設(shè)置 --> 文檔 --> 語義向量模型引擎 改為ollama黎棠, 語義向量模型改為bge-m3:latest
- 工作空間 --> 知識庫,點擊+號上傳文檔
- 使用時需要在聊天框通過
#
來指定知識庫 - 設(shè)置 --> 管理員設(shè)置 --> 數(shù)據(jù)庫 --> 下載數(shù)據(jù)庫镰绎,可以導(dǎo)出sqlite數(shù)據(jù)
小結(jié)
整體體驗是docker部署起來脓斩,頁面展示有點慢,聯(lián)網(wǎng)搜索一開始選擇serply不生效畴栖,換成tavily可以生效随静,但是國內(nèi)的搜索引擎還不支持。對于知識庫方面,可以上傳文檔和目錄燎猛,聊天窗口可以指定使用哪個知識庫恋捆,也可以同時開啟聯(lián)網(wǎng)搜索,整體效果還可以重绷,可以同時引用知識庫和搜索引擎的檢索結(jié)果沸停,看日志還會保存到向量數(shù)據(jù)庫(save_docs_to_vector_db
)。