nixos/open-webui: fix opensearch

When [adding Open WebUI as search engine in Firefox](https://docs.openwebui.com/tutorials/integrations/browser-search-engine/#for-firefox) it always links to `http://localhost:3000` instead of the configured port

It is because [the response use `WEBUI_URL` environment variable](1d225dd804/backend/open_webui/main.py (L2370)) which [is set by default to `1d225dd804/backend/open_webui/env.py (L106))
This commit is contained in:
pinage404 2024-09-30 13:55:09 +02:00
parent 20034e6dd4
commit 83b1350904
2 changed files with 15 additions and 0 deletions

View File

@ -93,6 +93,7 @@ in
DATA_DIR = "."; DATA_DIR = ".";
HF_HOME = "."; HF_HOME = ".";
SENTENCE_TRANSFORMERS_HOME = "."; SENTENCE_TRANSFORMERS_HOME = ".";
WEBUI_URL = "http://localhost:${toString cfg.port}";
} // cfg.environment; } // cfg.environment;
serviceConfig = { serviceConfig = {

View File

@ -31,6 +31,7 @@ in
testScript = '' testScript = ''
import json import json
import xml.etree.ElementTree as xml
machine.start() machine.start()
@ -45,5 +46,18 @@ in
# Check that the name was overridden via the environmentFile option. # Check that the name was overridden via the environmentFile option.
assert webui_config["name"] == "${webuiName} (Open WebUI)" assert webui_config["name"] == "${webuiName} (Open WebUI)"
webui_opensearch_xml = machine.succeed("curl http://127.0.0.1:${mainPort}/opensearch.xml")
webui_opensearch = xml.fromstring(webui_opensearch_xml)
webui_opensearch_url = webui_opensearch.find(
".//{http://a9.com/-/spec/opensearch/1.1/}Url"
)
assert (
webui_opensearch_url is not None
), f"no url tag found in {webui_opensearch_xml}"
assert (
webui_opensearch_url.get("template") == "http://localhost:8080/?q={searchTerms}"
), "opensearch url doesn't match the configured port"
''; '';
} }