mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Duplicated Info box
This commit is contained in:
parent
72e8b5c354
commit
b9eb927676
7 changed files with 204 additions and 170 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
@ -17,6 +17,8 @@
|
||||||
"editor.insertSpaces": true
|
"editor.insertSpaces": true
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"kvan"
|
"kvan",
|
||||||
|
"searx",
|
||||||
|
"searxng"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -49,7 +49,7 @@ def response(resp):
|
||||||
response_json = loads(resp.text)
|
response_json = loads(resp.text)
|
||||||
results = response_json['results']
|
results = response_json['results']
|
||||||
|
|
||||||
for i in ('answers', 'infoboxes'):
|
for i in ('answers', 'infoboxes', 'chat_box'):
|
||||||
results.extend(response_json[i])
|
results.extend(response_json[i])
|
||||||
|
|
||||||
results.extend({'suggestion': s} for s in response_json['suggestions'])
|
results.extend({'suggestion': s} for s in response_json['suggestions'])
|
||||||
|
|
17
searx/plugins/chat.py
Normal file
17
searx/plugins/chat.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
from searx.search import SearchWithPlugins
|
||||||
|
|
||||||
|
|
||||||
|
name = "Chat Plugin"
|
||||||
|
description = "Similar to bing GPT or google bard in their respective searches"
|
||||||
|
default_on = False
|
||||||
|
preference_section = 'general'
|
||||||
|
|
||||||
|
def post_search(request, search: SearchWithPlugins) -> None:
|
||||||
|
"""Called after the search is done."""
|
||||||
|
search_request = search.search_query
|
||||||
|
container = search.result_container
|
||||||
|
# container.infoboxes.append(container.infoboxes[0])
|
||||||
|
container.chat_box = container.infoboxes
|
||||||
|
print(search_request)
|
||||||
|
|
||||||
|
print("HELLO WORLD =====================================================================")
|
|
@ -157,6 +157,7 @@ class ResultContainer:
|
||||||
|
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
'_merged_results',
|
'_merged_results',
|
||||||
|
'chat_box',
|
||||||
'infoboxes',
|
'infoboxes',
|
||||||
'suggestions',
|
'suggestions',
|
||||||
'answers',
|
'answers',
|
||||||
|
@ -176,6 +177,7 @@ class ResultContainer:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._merged_results = []
|
self._merged_results = []
|
||||||
self.infoboxes = []
|
self.infoboxes = []
|
||||||
|
self.chat_box = []
|
||||||
self.suggestions = set()
|
self.suggestions = set()
|
||||||
self.answers = {}
|
self.answers = {}
|
||||||
self.corrections = set()
|
self.corrections = set()
|
||||||
|
|
|
@ -43,6 +43,17 @@
|
||||||
<p id="result_count"><small>{{ _('Number of results') }}: {{ number_of_results }}</small></p>
|
<p id="result_count"><small>{{ _('Number of results') }}: {{ number_of_results }}</small></p>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
|
{%- if chat_box -%}
|
||||||
|
<div id="chat_box">
|
||||||
|
<details open class="sidebar-collapsable">
|
||||||
|
<summary class="title">{{ _('Info') }}</summary>
|
||||||
|
{%- for infobox in infoboxes -%}
|
||||||
|
{%- include 'kvanDark/elements/infobox.html' -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
{%- if infoboxes -%}
|
{%- if infoboxes -%}
|
||||||
<div id="infoboxes">
|
<div id="infoboxes">
|
||||||
<details open class="sidebar-collapsable">
|
<details open class="sidebar-collapsable">
|
||||||
|
|
|
@ -779,6 +779,7 @@ def search():
|
||||||
answers = result_container.answers,
|
answers = result_container.answers,
|
||||||
corrections = correction_urls,
|
corrections = correction_urls,
|
||||||
infoboxes = result_container.infoboxes,
|
infoboxes = result_container.infoboxes,
|
||||||
|
chat_box = result_container.chat_box,
|
||||||
engine_data = result_container.engine_data,
|
engine_data = result_container.engine_data,
|
||||||
paging = result_container.paging,
|
paging = result_container.paging,
|
||||||
unresponsive_engines = webutils.get_translated_errors(
|
unresponsive_engines = webutils.get_translated_errors(
|
||||||
|
|
|
@ -164,6 +164,7 @@ def get_json_response(sq: SearchQuery, rc: ResultContainer) -> str:
|
||||||
'answers': list(rc.answers),
|
'answers': list(rc.answers),
|
||||||
'corrections': list(rc.corrections),
|
'corrections': list(rc.corrections),
|
||||||
'infoboxes': rc.infoboxes,
|
'infoboxes': rc.infoboxes,
|
||||||
|
'chat_box': rc.chat_box,
|
||||||
'suggestions': list(rc.suggestions),
|
'suggestions': list(rc.suggestions),
|
||||||
'unresponsive_engines': get_translated_errors(rc.unresponsive_engines),
|
'unresponsive_engines': get_translated_errors(rc.unresponsive_engines),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue