f4a003d355
Adds an optional plugin that shows a generated summary above the search results, similar to the answer boxes in Brave and Google. The text is produced by an LLM server the administrator runs, reached over the OpenAI chat completions API, so queries never leave the operator's own network. The summary is grounded on the top search results rather than the model's training data. It is generated asynchronously: post_search adds an empty placeholder and returns, and the browser fills it from the /ai_summary endpoint, which streams the answer as NDJSON. No summary is generated beyond page one, outside the general category, for non-HTML formats, or when an engine already answered with an infobox or an instant answer. The client side follows the existing plugin pattern: one file in client/simple/src/js/plugin/, one conditional load in router.ts, one LESS import. No build configuration changes and no new dependencies. The plugin is not activated by default. Instance defaults live in an ai_summary: section; the server, model, API key and grounding are user preferences, and all four can be locked. Signed-off-by: Jason Witty <jasonpwitty+github@proton.me>
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Implementation of the :py:obj:`preference <searx.preference>` settings."""
|
|
# pylint: disable = too-few-public-methods
|
|
|
|
import typing as t
|
|
import msgspec
|
|
|
|
|
|
class SettingsPref(msgspec.Struct, kw_only=True, forbid_unknown_fields=True):
|
|
"""Options for configuring the preferences
|
|
|
|
.. code:: yaml
|
|
|
|
preferences:
|
|
lock:
|
|
- favicon_resolver
|
|
- image_proxy
|
|
- method
|
|
# ...
|
|
|
|
"""
|
|
|
|
lock: set[
|
|
t.Literal[
|
|
"categories",
|
|
"language",
|
|
"locale",
|
|
"autocomplete",
|
|
"favicon_resolver",
|
|
"image_proxy",
|
|
"method",
|
|
"safesearch",
|
|
"theme",
|
|
"results_on_new_tab",
|
|
"doi_resolver",
|
|
"ai_summary_server",
|
|
"ai_summary_model",
|
|
"ai_summary_grounding",
|
|
"simple_style",
|
|
"center_alignment",
|
|
"query_in_title",
|
|
"search_on_category_select",
|
|
]
|
|
] = set()
|
|
"""Lock arbitrary settings on the preferences page."""
|