mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-03 18:17:56 -05:00
The info log was filled with step-by-step lines that fire on every chat with knowledge or web search, chat search, file upload, document parsing, knowledge base update or search, image generation, note chat and collaborative note editing, so running at INFO in production buried the lines an admin actually needs. Every sign-in also wrote the user's email address to the info log. These lines, the email one included, now only show with GLOBAL_LOG_LEVEL=DEBUG. Results such as documents added to or removed from the vector database and admin actions keep their line at info. A few unused internal leftovers are removed, which no setting or feature relied on. Fixes #35535
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
import logging
|
|
|
|
import requests
|
|
from open_webui.retrieval.web.main import SearchResult
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
EXA_API_BASE = 'https://api.exa.ai'
|
|
|
|
|
|
def search_exa(
|
|
api_key: str,
|
|
query: str,
|
|
count: int,
|
|
filter_list: list[str] | None = None,
|
|
max_content_length: int | None = None,
|
|
) -> list[SearchResult]:
|
|
"""Search using Exa Search API and return the results as a list of SearchResult objects.
|
|
|
|
Args:
|
|
api_key (str): A Exa Search API key
|
|
query (str): The query to search for
|
|
count (int): Number of results to return
|
|
filter_list (list[str] | None): List of domains to filter results by
|
|
max_content_length (int | None): Maximum characters per result; None leaves text unlimited.
|
|
"""
|
|
log.debug('Searching with Exa')
|
|
|
|
headers = {'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
|
|
|
|
payload = {
|
|
'query': query,
|
|
'numResults': count or 5,
|
|
'includeDomains': filter_list,
|
|
'contents': {'text': {'maxCharacters': max_content_length} if max_content_length is not None else True},
|
|
'type': 'auto', # Use the auto search type (keyword or neural)
|
|
}
|
|
|
|
try:
|
|
response = requests.post(f'{EXA_API_BASE}/search', headers=headers, json=payload)
|
|
response.raise_for_status()
|
|
data = response.json()
|
|
|
|
results = data['results']
|
|
log.debug('Found %s results', len(results))
|
|
return [
|
|
SearchResult(
|
|
link=result['url'],
|
|
title=result['title'],
|
|
snippet=(result.get('text') or '')[:max_content_length],
|
|
)
|
|
for result in results
|
|
]
|
|
except Exception as e:
|
|
log.error(f'Error searching Exa: {e}')
|
|
return []
|