fix: ensure plugin stays active by returning True in init and update README
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
# SearXNG Gemini Stream Plugin
|
||||
# SearXNG Gemini Stream
|
||||
|
||||
This is a SearXNG plugin that provides live AI search answers using Google Gemini Flash.
|
||||
A SearXNG plugin that streams an AI response using results as grounding context to an Answer box at the top of results.
|
||||
|
||||
## Configuration
|
||||
|
||||
Set the following environment variables:
|
||||
- `GEMINI_API_KEY`: Your Google Gemini API key.
|
||||
- `GEMINI_MODEL`: (Optional) The model to use, defaults to `gemini-3-flash-preview`.
|
||||
- `GEMINI_MODEL`: (Optional) Defaults to `gemini-3-flash-preview`.
|
||||
|
||||
### settings.yml
|
||||
Add this to your SearXNG configuration file to enable the plugin:
|
||||
|
||||
```yaml
|
||||
plugins:
|
||||
- name: gemini_flash
|
||||
active: true
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
This file should be placed in the `searx/plugins` directory of your SearXNG instance or configured as a plugin.
|
||||
Place `gemini_flash.py` into the `searx/plugins` directory of your instance.
|
||||
|
||||
+2
-4
@@ -18,7 +18,6 @@ class SXNGPlugin(Plugin):
|
||||
description=gettext("Live AI search answers using Google Gemini Flash"),
|
||||
preference_section="general",
|
||||
)
|
||||
self.active = plg_cfg.active
|
||||
self.api_key = os.getenv('GEMINI_API_KEY')
|
||||
self.model = os.getenv('GEMINI_MODEL', 'gemini-3-flash-preview')
|
||||
self.tokens = {}
|
||||
@@ -123,12 +122,9 @@ USER QUERY: {q}
|
||||
|
||||
@app.route('/gemini.js')
|
||||
def g_script():
|
||||
# Get parameters from the SCRIPT SRC url
|
||||
token = request.args.get('token', '')
|
||||
query = request.args.get('q', '')
|
||||
|
||||
# Safe injection of query into the JS string
|
||||
# We use json.dumps to ensure it is a valid JS string literal (handles quotes/escapes)
|
||||
js_query = json.dumps(query)
|
||||
js_token = json.dumps(token)
|
||||
|
||||
@@ -161,6 +157,8 @@ USER QUERY: {q}
|
||||
"""
|
||||
return Response(js_code, mimetype='application/javascript')
|
||||
|
||||
return True
|
||||
|
||||
def post_search(self, request, search) -> EngineResults:
|
||||
results = EngineResults()
|
||||
if search.search_query.pageno > 1 or not self.active or not self.api_key:
|
||||
|
||||
Reference in New Issue
Block a user