Files
open-webui/backend/open_webui/retrieval/web/ollama.py
T
Classic298 03cdec3fab fix: info logs flooded by per-request trace lines (#35538)
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
2026-12-03 00:32:29 +04:00

53 lines
1.5 KiB
Python

import logging
from dataclasses import dataclass
from typing import Optional
import requests
from open_webui.retrieval.web.main import SearchResult, get_filtered_results
log = logging.getLogger(__name__)
def search_ollama_cloud(
url: str,
api_key: str,
query: str,
count: int,
filter_list: Optional[list[str]] = None,
) -> list[SearchResult]:
"""Search using Ollama Search API and return the results as a list of SearchResult objects.
Args:
api_key (str): A Ollama Search API key
query (str): The query to search for
count (int): Number of results to return
filter_list (Optional[list[str]]): List of domains to filter results by
"""
log.debug('Searching with Ollama')
headers = {'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
payload = {'query': query, 'max_results': count}
try:
response = requests.post(f'{url}/api/web_search', headers=headers, json=payload)
response.raise_for_status()
data = response.json()
results = data.get('results', [])
log.debug('Found %s results', len(results))
if filter_list:
results = get_filtered_results(results, filter_list)
return [
SearchResult(
link=result.get('url', ''),
title=result.get('title', ''),
snippet=result.get('content', ''),
)
for result in results
]
except Exception as e:
log.error(f'Error searching Ollama: {e}')
return []