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
|
||||
},
|
||||
"cSpell.words": [
|
||||
"kvan"
|
||||
"kvan",
|
||||
"searx",
|
||||
"searxng"
|
||||
]
|
||||
}
|
|
@ -49,7 +49,7 @@ def response(resp):
|
|||
response_json = loads(resp.text)
|
||||
results = response_json['results']
|
||||
|
||||
for i in ('answers', 'infoboxes'):
|
||||
for i in ('answers', 'infoboxes', 'chat_box'):
|
||||
results.extend(response_json[i])
|
||||
|
||||
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__ = (
|
||||
'_merged_results',
|
||||
'chat_box',
|
||||
'infoboxes',
|
||||
'suggestions',
|
||||
'answers',
|
||||
|
@ -176,6 +177,7 @@ class ResultContainer:
|
|||
super().__init__()
|
||||
self._merged_results = []
|
||||
self.infoboxes = []
|
||||
self.chat_box = []
|
||||
self.suggestions = set()
|
||||
self.answers = {}
|
||||
self.corrections = set()
|
||||
|
|
|
@ -43,6 +43,17 @@
|
|||
<p id="result_count"><small>{{ _('Number of results') }}: {{ number_of_results }}</small></p>
|
||||
{%- 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 -%}
|
||||
<div id="infoboxes">
|
||||
<details open class="sidebar-collapsable">
|
||||
|
|
|
@ -779,6 +779,7 @@ def search():
|
|||
answers = result_container.answers,
|
||||
corrections = correction_urls,
|
||||
infoboxes = result_container.infoboxes,
|
||||
chat_box = result_container.chat_box,
|
||||
engine_data = result_container.engine_data,
|
||||
paging = result_container.paging,
|
||||
unresponsive_engines = webutils.get_translated_errors(
|
||||
|
|
|
@ -164,6 +164,7 @@ def get_json_response(sq: SearchQuery, rc: ResultContainer) -> str:
|
|||
'answers': list(rc.answers),
|
||||
'corrections': list(rc.corrections),
|
||||
'infoboxes': rc.infoboxes,
|
||||
'chat_box': rc.chat_box,
|
||||
'suggestions': list(rc.suggestions),
|
||||
'unresponsive_engines': get_translated_errors(rc.unresponsive_engines),
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue