前回の続きからやっていきます。
SearXNG の導入
参考:https://docs.openwebui.com/features/chat-conversations/web-search/providers/searxng/
- ローカルに serxng コンテナ準備用のフォルダを用意します。
mkdir c:\OpenWebUI\searxng -force - 以下のコマンドで searxng コンテナを起動します。(初回はイメージダウンロードもしてくれます)
# 設定ファイルをマウントして、コンテナを作成する docker run -d --name searxng -p 8080:8080 -v c:\OpenWebUI\searxng:/etc/searxng:rw --restart unless-stopped searxng/searxng:latest - http://localhost:8080 をアクセスし、検索画面が出れば成功
- open-webui コンテナから通信テストを行います。
docker exec -i open-webui sh -c "curl -v 'http://searxng:8080/search?q=dokcer&format=json'" # 名前解決できないエラーが吐くはず # Could not resolve host: searxng - Docker ネットワークを作成し、コンテナ達をネットワークに入れます。
# ネットワーク作成 docker netowork create ai-network # コンテナを Dokcer ネットワークに追加 docker network connect ai-network searxng docker network connect ai-network open-webui - 再度 open-webui コンテナから通信テストを行います。
docker exec -i open-webui sh -c "curl -v 'http://searxng:8080/search?q=dokcer&format=json'" # 何かしらの結果が返ってきます。403 とか出たら、searxng を再起動してみてください。 - open-webui は json の応答が必要なので、上記のテスト結果のように html 形式で帰ってきます。searxng の設定が必要なので、設定を以下のように行います。
a. searxng 作成時にマウントした c:\OpenWebUI\searxng を開きます。 b. 中に setting.yml ファイルが作成されているはずなので、ファイルを開きます。 c. "search:" セクターの "formats:"(85 行あたり)に "- json" を追加します。追加後以下のようになります。 formats: - html - json d. 保存して閉じます。 - searxng と open-webui を再起動します。
docker restart searxng docker restart open-webui - 以下のコマンドで、json 形式のレスポンスが返ってくるかを確認します。
# コマンドの部分は必ず '' を囲んでやってください。でないと、json 部分の指定は認識されない docker exec -i open-webui sh -c "curl 'http://searxng:8080/search?q=test&format=json'" - 一旦前回作成した OpenWebUI コンテナを作成して、searxng で検索する指定を環境変数で設定するように再作成します。※ このステップをスキップして、step 11 以降の手順で、そのままのコンテナで GUI で設定することも可能
# コンテナ削除 docker stop open-webui docker rm open-webui # 再起動 docker run -d ` -p 3000:8080 ` -v open-webui:/app/backend/data ` -e ENABLE_RAG_WEB_SEARCH=True ` -e ENABLE_RAG_LOCAL_WEB_FETCH=True ` -e RAG_WEB_SEARCH_ENGINE=searxng ` -e RAG_WEB_SEARCH_RESULT_COUNT=10 ` -e RAG_WEB_SEARCH_CONCURRENT_REQUESTS=3 ` -e SEARXNG_QUERY_URL="http://searxng:8080/search?q=<query>&format=json" ` --name open-webui ` ghcr.io/open-webui/open-webui:cuda # RAG_WEB_SEARCH_CONCURRENT_REQUESTS 数値が高すぎると、処理が失敗することがあるので、注意 # 再度 docker network に参加させる docker network connect ai-network open-webui - http://localhost:3000 で OpenWeb UI へアクセスし、右上のユーザー アイコンをクリックし、「管理者パネル」をクリックします。

- 上部の「設定」タブをクリックし、「ウェブ検索」→「ウェブ検索」をオンにし、「ウェブ検索エンジン」を「searxng」を指定し、URL が入ってない場合、
http://searxng:8080/search?q=<query>&format=jsonを入れて、保存をクリックします。

- 「モデル」タブを選択し、使っているモデルの編集(ペン)ボタンをクリックします。

- 「デフォルト機能」のところで、「ウェブ検索」にチェックを入れて、保存します。

- 質問してみます。

コメント