From 7917128ed3a3b7806565bf9f3d924750b84008f8 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 8 Mar 2025 00:43:02 -0500 Subject: [PATCH 1/2] enh: enable configuration for tavily extract depth --- backend/open_webui/config.py | 6 ++++++ backend/open_webui/main.py | 2 ++ backend/open_webui/retrieval/web/utils.py | 2 ++ 3 files changed, 10 insertions(+) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 1e265f2ce..9ab225c58 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1950,6 +1950,12 @@ TAVILY_API_KEY = PersistentConfig( os.getenv("TAVILY_API_KEY", ""), ) +TAVILY_EXTRACT_DEPTH = PersistentConfig( + "TAVILY_EXTRACT_DEPTH", + "rag.web.search.tavily_extract_depth", + int(os.getenv("TAVILY_EXTRACT_DEPTH", "basic")), +) + JINA_API_KEY = PersistentConfig( "JINA_API_KEY", "rag.web.search.jina_api_key", diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 416460837..e7d9f7aec 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -212,6 +212,7 @@ from open_webui.config import ( SERPSTACK_API_KEY, SERPSTACK_HTTPS, TAVILY_API_KEY, + TAVILY_EXTRACT_DEPTH, BING_SEARCH_V7_ENDPOINT, BING_SEARCH_V7_SUBSCRIPTION_KEY, BRAVE_SEARCH_API_KEY, @@ -614,6 +615,7 @@ app.state.config.RAG_WEB_SEARCH_TRUST_ENV = RAG_WEB_SEARCH_TRUST_ENV app.state.config.PLAYWRIGHT_WS_URI = PLAYWRIGHT_WS_URI app.state.config.FIRECRAWL_API_BASE_URL = FIRECRAWL_API_BASE_URL app.state.config.FIRECRAWL_API_KEY = FIRECRAWL_API_KEY +app.state.config.TAVILY_EXTRACT_DEPTH = TAVILY_EXTRACT_DEPTH app.state.EMBEDDING_FUNCTION = None app.state.ef = None diff --git a/backend/open_webui/retrieval/web/utils.py b/backend/open_webui/retrieval/web/utils.py index cffa1b5aa..65654d8e8 100644 --- a/backend/open_webui/retrieval/web/utils.py +++ b/backend/open_webui/retrieval/web/utils.py @@ -33,6 +33,7 @@ from open_webui.config import ( FIRECRAWL_API_BASE_URL, FIRECRAWL_API_KEY, TAVILY_API_KEY, + TAVILY_EXTRACT_DEPTH, ) from open_webui.env import SRC_LOG_LEVELS @@ -613,6 +614,7 @@ def get_web_loader( if RAG_WEB_LOADER_ENGINE.value == "tavily": web_loader_args["api_key"] = TAVILY_API_KEY.value + web_loader_args["extract_depth"] = TAVILY_EXTRACT_DEPTH.value # Create the appropriate WebLoader based on the configuration WebLoaderClass = RAG_WEB_LOADER_ENGINES[RAG_WEB_LOADER_ENGINE.value] From 7c4a9c2aea9690cabb5a61c9a4c3c154669a7234 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 8 Mar 2025 01:07:06 -0500 Subject: [PATCH 2/2] fix: correct type handling for TAVILY_EXTRACT_DEPTH configuration --- backend/open_webui/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 9ab225c58..34004c76d 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1953,7 +1953,7 @@ TAVILY_API_KEY = PersistentConfig( TAVILY_EXTRACT_DEPTH = PersistentConfig( "TAVILY_EXTRACT_DEPTH", "rag.web.search.tavily_extract_depth", - int(os.getenv("TAVILY_EXTRACT_DEPTH", "basic")), + os.getenv("TAVILY_EXTRACT_DEPTH", "basic"), ) JINA_API_KEY = PersistentConfig(