mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Moved GPT4all to chat plugin more
This commit is contained in:
parent
11a2d26393
commit
3f9f8940ec
3 changed files with 56 additions and 57 deletions
|
|
@ -1,4 +1,6 @@
|
|||
from searx.search import SearchWithPlugins
|
||||
from pathlib import Path
|
||||
from gpt4all import GPT4All
|
||||
|
||||
|
||||
name = "Chat Plugin"
|
||||
|
|
@ -11,5 +13,29 @@ def post_search(request, search: SearchWithPlugins) -> None:
|
|||
search_request = search.search_query
|
||||
container = search.result_container
|
||||
# container.infoboxes.append(container.infoboxes[0])
|
||||
container.chat_box = [{'chat_box': 'hello world'}]
|
||||
container.chat_box[0]['content'] = 'some string that relates to your search query here' + f'\n{search_request.query}'
|
||||
container.chat_box = {'chat_box': 'GPT4All'}
|
||||
container.chat_box['content'] = 'Generating response to query: ' + f'\n{search_request.query}'
|
||||
|
||||
def generate_chat_content(query):
|
||||
model = GPT4All(model_name='gpt4all-falcon-q4_0.gguf',
|
||||
model_path=(Path.cwd() / 'searx' / 'plugins'),
|
||||
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., `<div>`, `<p>`, `<h1>`) to structure the response. Do not use markdown syntax or backticks(```) to format the response.
|
||||
3. Directly address the query. For example, if the query is about a specific function or method in a programming language, focus on explaining and providing examples of that function or method.
|
||||
4. Include practical examples or code snippets relevant to the query.
|
||||
5. Keep definitions or explanations brief and specific, focusing only on aspects directly related to the query.
|
||||
"""
|
||||
|
||||
prompt_template = """
|
||||
### Query:
|
||||
{0}
|
||||
|
||||
### Expected Information Box:
|
||||
"""
|
||||
with model.chat_session(system_template, prompt_template):
|
||||
response = model.generate(query, max_tokens=500, repeat_penalty=1.3)
|
||||
return str(response)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue