mirror of
https://github.com/open-webui/open-webui
synced 2025-05-18 20:31:36 +00:00
Update tavily.py
This commit is contained in:
parent
893bfe9d3a
commit
5ca39eb9fd
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from open_webui.retrieval.web.main import SearchResult
|
from open_webui.retrieval.web.main import SearchResult
|
||||||
@ -8,7 +9,13 @@ log = logging.getLogger(__name__)
|
|||||||
log.setLevel(SRC_LOG_LEVELS["RAG"])
|
log.setLevel(SRC_LOG_LEVELS["RAG"])
|
||||||
|
|
||||||
|
|
||||||
def search_tavily(api_key: str, query: str, count: int) -> list[SearchResult]:
|
def search_tavily(
|
||||||
|
api_key: str,
|
||||||
|
query: str,
|
||||||
|
count: int,
|
||||||
|
filter_list: Optional[list[str]] = None,
|
||||||
|
# **kwargs,
|
||||||
|
) -> list[SearchResult]:
|
||||||
"""Search using Tavily's Search API and return the results as a list of SearchResult objects.
|
"""Search using Tavily's Search API and return the results as a list of SearchResult objects.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -20,8 +27,8 @@ def search_tavily(api_key: str, query: str, count: int) -> list[SearchResult]:
|
|||||||
"""
|
"""
|
||||||
url = "https://api.tavily.com/search"
|
url = "https://api.tavily.com/search"
|
||||||
data = {"query": query, "api_key": api_key}
|
data = {"query": query, "api_key": api_key}
|
||||||
|
include_domain = filter_list
|
||||||
response = requests.post(url, json=data)
|
response = requests.post(url, include_domain, json=data)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
json_response = response.json()
|
json_response = response.json()
|
||||||
|
Loading…
Reference in New Issue
Block a user