feat: web search available is inferred from env vars

This commit is contained in:
Jun Siang Cheah 2024-05-12 15:19:52 +08:00
parent 9ed1a31575
commit d45804d7f4
6 changed files with 13 additions and 1 deletions

View File

@ -563,6 +563,13 @@ BRAVE_SEARCH_API_KEY = os.getenv("BRAVE_SEARCH_API_KEY", "")
SERPSTACK_API_KEY = os.getenv("SERPSTACK_API_KEY", "")
SERPSTACK_HTTPS = os.getenv("SERPSTACK_HTTPS", "True").lower() == "true"
SERPER_API_KEY = os.getenv("SERPER_API_KEY", "")
RAG_WEB_SEARCH_ENABLED = (
SEARXNG_QUERY_URL != ""
or (GOOGLE_PSE_API_KEY != "" and GOOGLE_PSE_ENGINE_ID != "")
or BRAVE_SEARCH_API_KEY != ""
or SERPSTACK_API_KEY != ""
or SERPER_API_KEY != ""
)
RAG_WEB_SEARCH_RESULT_COUNT = int(os.getenv("RAG_WEB_SEARCH_RESULT_COUNT", "10"))
RAG_WEB_SEARCH_CONCURRENT_REQUESTS = int(
os.getenv("RAG_WEB_SEARCH_CONCURRENT_REQUESTS", "10")

View File

@ -58,6 +58,7 @@ from config import (
SRC_LOG_LEVELS,
WEBHOOK_URL,
ENABLE_ADMIN_EXPORT,
RAG_WEB_SEARCH_ENABLED,
)
from constants import ERROR_MESSAGES
@ -248,6 +249,7 @@ async def get_app_config():
"default_prompt_suggestions": webui_app.state.DEFAULT_PROMPT_SUGGESTIONS,
"trusted_header_auth": bool(webui_app.state.AUTH_TRUSTED_EMAIL_HEADER),
"admin_export_enabled": ENABLE_ADMIN_EXPORT,
"websearch": RAG_WEB_SEARCH_ENABLED,
}

View File

@ -47,7 +47,7 @@
export let fileUploadEnabled = true;
export let speechRecognitionEnabled = true;
export let webSearchAvailable = true; // TODO: Default to false
export let webSearchAvailable = false;
export let useWebSearch = false;
export let prompt = '';

View File

@ -129,6 +129,7 @@ type Config = {
default_models?: string[];
default_prompt_suggestions?: PromptSuggestion[];
trusted_header_auth?: boolean;
websearch?: boolean;
};
type PromptSuggestion = {

View File

@ -977,4 +977,5 @@
{messages}
{submitPrompt}
{stopResponse}
webSearchAvailable={$config.websearch ?? false}
/>

View File

@ -994,5 +994,6 @@
{messages}
{submitPrompt}
{stopResponse}
webSearchAvailable={$config.websearch ?? false}
/>
{/if}