from searx.search import SearchWithPlugins
from pathlib import Path
from gpt4all import GPT4All
import os
name = "Chat Plugin"
description = "[REQUIRES ENGINE TOKEN] Similar to bing GPT or google bard in their respective searches"
default_on = False
preference_section = 'general'
tokens = ['14d3466459a9ee5d264918af4071450d7fc67ec5199bbd4ead326601967f6991']
def post_search(request, search: SearchWithPlugins) -> None:
"""Called after the search is done."""
search_request = search.search_query
container = search.result_container
container.chat_box = {'chat_box': 'GPT4All'}
container.chat_box['content'] = 'Generating response to query:
' + f'\n{search_request.query}'
container.chat_box['code'] = 202
def generate_chat_content(query):
script_directory = Path(os.path.dirname(__file__))
model = GPT4All(model_name='gpt4all-falcon-q4_0.gguf',
model_path=script_directory,
allow_download=False)
system_template = """
### System Instructions:
1. Provide concise and directly relevant answers to the specific query in HTML format, emulating the style of an info box on a search engine.
2. Only use appropriate HTML tags (e.g., `
`, `