feat: add support for SearXNG HTTP basic authentication

This commit is contained in:
Michael
2026-06-30 22:37:05 +02:00
parent 5203cf89a0
commit 031c3461df
3 changed files with 41 additions and 7 deletions
+7
View File
@@ -14,6 +14,8 @@ class AgentSettings(BaseSettings):
agent_model_id: str = "qwen/qwen3.6-35b-a3b"
agent_max_retries: int = 2
searxng_url: str = ""
searxng_username: str = ""
searxng_password: str = ""
def get_settings() -> AgentSettings:
@@ -30,9 +32,14 @@ GITEA_REPOS_ROOT: str = _agent_settings.gitea_repos_root
AGENT_MODEL_ID: str = _agent_settings.agent_model_id
AGENT_MAX_RETRIES: int = _agent_settings.agent_max_retries
SEARXNG_URL: str = _agent_settings.searxng_url
SEARXNG_USERNAME: str = _agent_settings.searxng_username
SEARXNG_PASSWORD: str = _agent_settings.searxng_password
import os
os.environ["GITEA_SERVER_URL"] = GITEA_URL
os.environ["GITEA_SERVER_TOKEN"] = GITEA_TOKEN
os.environ["SEARXNG_URL"] = SEARXNG_URL
os.environ["SEARXNG_USERNAME"] = SEARXNG_USERNAME
os.environ["SEARXNG_PASSWORD"] = SEARXNG_PASSWORD
+9 -2
View File
@@ -26,7 +26,7 @@ from duckduckgo_search.exceptions import ( # type: ignore[import-untyped]
RatelimitException,
)
from gitea.config import SEARXNG_URL
from gitea.config import SEARXNG_URL, SEARXNG_USERNAME, SEARXNG_PASSWORD
logger: logging.Logger = logging.getLogger("research-tools")
@@ -38,6 +38,9 @@ _USER_AGENT: str = (
)
# SearXNG instance
_SEARXNG_URL: str = SEARXNG_URL
_SEARXNG_USERNAME: str = SEARXNG_USERNAME
_SEARXNG_PASSWORD: str = SEARXNG_PASSWORD
@@ -196,9 +199,13 @@ class ResearchTools:
if time_range:
params["time_range"] = time_range
auth = None
if _SEARXNG_USERNAME and _SEARXNG_PASSWORD:
auth = (_SEARXNG_USERNAME, _SEARXNG_PASSWORD)
try:
with httpx.Client(
timeout=_DEFAULT_TIMEOUT, follow_redirects=True
timeout=_DEFAULT_TIMEOUT, follow_redirects=True, auth=auth
) as client:
response = client.get(
f"{_SEARXNG_URL}/search",