mirror of
https://github.com/searxng/searxng.git
synced 2025-02-20 12:20:04 +00:00
[mod] tavily engine: revert double punctuation & remove f-stringed gettexts
This commit is contained in:
parent
1a3ffdb4ea
commit
e4e6f21494
@ -6,7 +6,7 @@
|
||||
Before reporting an issue with this engine,
|
||||
please consult `API error codes`_.
|
||||
|
||||
Tavily_ search API (AI engine). This engine implements the REST API
|
||||
Tavily_ search API (AI engine). This engine implements the REST API
|
||||
(`POST /search`_) and does not make use of the `Tavily Python Wrapper`_.
|
||||
|
||||
From the API response, this engine generates *result items* (shown in the main
|
||||
@ -17,7 +17,7 @@ into an *infobox result*.
|
||||
.. attention::
|
||||
|
||||
AI queries take considerably longer to process than queries to conventional
|
||||
search engines. The ``timeout`` should therefore also be set considerably
|
||||
search engines. The ``timeout`` should therefore also be set considerably
|
||||
higher, but it is not recommended to activate AI queries by default
|
||||
(set ``disabled: true``), as otherwise all user searches will have to wait
|
||||
for the AI.
|
||||
@ -93,7 +93,7 @@ about = {
|
||||
"official_api_documentation": "https://docs.tavily.com/docs/rest-api/api-reference",
|
||||
"use_official_api": True,
|
||||
"require_api_key": True,
|
||||
"results": 'JSON',
|
||||
"results": "JSON",
|
||||
}
|
||||
|
||||
search_url = "https://api.tavily.com/search"
|
||||
@ -104,31 +104,31 @@ api_key: str = "unset"
|
||||
"""Tavily API Key (`Getting started`_)."""
|
||||
|
||||
search_depth: str = "basic"
|
||||
"""The depth of the search. It can be ``basic`` or ``advanced``. Default is
|
||||
"""The depth of the search. It can be ``basic`` or ``advanced``. Default is
|
||||
``basic`` unless specified otherwise in a given method.
|
||||
|
||||
- have an eye on your `Tavily API Credit Deduction`_!
|
||||
"""
|
||||
|
||||
topic: str = ""
|
||||
"""The category of the search. This will determine which of Tavily's agents
|
||||
will be used for the search. Currently, only ``general`` and ``news`` are
|
||||
"""The category of the search. This will determine which of Tavily's agents
|
||||
will be used for the search. Currently, only ``general`` and ``news`` are
|
||||
supported."""
|
||||
|
||||
days: int = 3
|
||||
"""The number of days back from the current date to include in the search results.
|
||||
This specifies the time frame of data to be retrieved. Please note that this
|
||||
This specifies the time frame of data to be retrieved. Please note that this
|
||||
feature is only available when using the ``news`` search topic. Default is 3."""
|
||||
|
||||
max_results: int = 5
|
||||
"""The maximum number of search results to return. Default is 5."""
|
||||
"""The maximum number of search results to return. Default is 5."""
|
||||
|
||||
include_answer: bool = True
|
||||
"""Include a short answer to the original query, generated by an LLM based on Tavily's
|
||||
search results."""
|
||||
|
||||
include_images: bool = False
|
||||
"""Include a list of query-related images in the response. Creates an infobox
|
||||
"""Include a list of query-related images in the response. Creates an infobox
|
||||
with the first image (as far as there are any images in the response) and the answer,
|
||||
if ``include_answer`` is also enabled.
|
||||
"""
|
||||
@ -185,9 +185,9 @@ def response(resp):
|
||||
for result in data.get("results", []):
|
||||
results.append(
|
||||
{
|
||||
"title": result['title'],
|
||||
"title": result["title"],
|
||||
"url": result["url"],
|
||||
"content": f"[{gettext('ai')}] {result['content']}",
|
||||
"content": "[" + gettext("ai") + "] " + result["content"],
|
||||
"publishedDate": _parse_date(result.get("published_date")),
|
||||
}
|
||||
)
|
||||
@ -195,18 +195,18 @@ def response(resp):
|
||||
img_list = data.get("images")
|
||||
if img_list:
|
||||
result = {
|
||||
"infobox": f"Tavily [{gettext('ai')}]",
|
||||
"infobox": "Tavily [" + gettext("ai") + "]",
|
||||
"img_src": img_list[0],
|
||||
}
|
||||
|
||||
content = data.get("answer")
|
||||
if isinstance(img_list[0], dict):
|
||||
result["img_src"] = img_list[0]["url"]
|
||||
img_caption = f"<i>{gettext('Image caption')}</i>: {img_list[0]['description']}"
|
||||
img_caption = gettext("Image caption") + ": " + img_list[0]["description"]
|
||||
if not content:
|
||||
result["content"] = img_caption
|
||||
else:
|
||||
result["content"] = f"{content}<br/>{img_caption}"
|
||||
result["content"] = content + "//" + img_caption
|
||||
elif content:
|
||||
result["content"] = content
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user