diff --git a/ollama_answers.py b/ollama_answers.py index cd590cb..0cdfe01 100644 --- a/ollama_answers.py +++ b/ollama_answers.py @@ -7,7 +7,7 @@ except ImportError: get_network = None from flask import Response, request, abort, jsonify from searx.plugins import Plugin, PluginInfo -from searx.result_types import Answer +from searx.result_types import EngineResults, Answer from searx import settings from flask_babel import gettext from markupsafe import Markup @@ -630,22 +630,23 @@ class SXNGPlugin(Plugin): return "\n\n".join(context_parts), result_urls - def post_search(self, request: "SXNG_Request", search: "SearchWithPlugins") -> list: + def post_search(self, request: "SXNG_Request", search: "SearchWithPlugins") -> EngineResults: + results = EngineResults() try: if request and hasattr(request, 'headers') and request.headers.get('X-AI-Auxiliary'): - return [] + return results if request and request.form.get('format', 'html') != 'html': - return [] + return results if self.question_mark_required and '?' not in search.search_query.query: - return [] + return results current_tabs = set(search.search_query.categories) if not current_tabs: current_tabs = {'general'} if not self.active or not self.api_key or search.search_query.pageno > 1 or not self.allowed_tabs.intersection(current_tabs): - return [] + return results raw_results = search.result_container.get_ordered_results() raw_infoboxes = getattr(search.result_container, 'infoboxes', []) @@ -769,7 +770,7 @@ class SXNGPlugin(Plugin): ''' - return [Answer(answer=Markup(html_payload))] + results.answers.add(Answer(answer=Markup(html_payload))) except Exception as e: logger.error(f"{PLUGIN_NAME}: {e}") - return [] \ No newline at end of file + return results \ No newline at end of file