From c2286ae0a61b506fa1a87be65a4563f9e17b5d73 Mon Sep 17 00:00:00 2001 From: fram3d Date: Tue, 6 Feb 2024 02:00:41 +0100 Subject: [PATCH 1/2] add ollama command --- .gitignore | 1 + functions.py | 7 +++++++ requirements.txt | 1 + 3 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 948a4f4..7cfbc19 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.ini +venv/ __pycache__ diff --git a/functions.py b/functions.py index 6a2fc5c..348f71d 100644 --- a/functions.py +++ b/functions.py @@ -1,3 +1,5 @@ +import ollama + def processmsg(msg, rcpt): if msg.startswith("!"): return command(msg, rcpt) @@ -7,3 +9,8 @@ def processmsg(msg, rcpt): def command(msg, rcpt): if msg.startswith("!help"): return "chatbot commands: \n" + "!help Show this help page" + elif msg.startswith("!ai"): + client = ollama.Client(host='https://ollama.krov.dmz.rs') + response = client.chat(model='llama2-uncensored:latest', messages=[{'role':'user','content':f'{msg[4:]}'}]) + return(response['message']['content']) + diff --git a/requirements.txt b/requirements.txt index 5593b66..e1e7e30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ slixmpp +ollama From bc2e7422f5573d0b9c88ee36eae456ba02361fd0 Mon Sep 17 00:00:00 2001 From: fram3d Date: Tue, 6 Feb 2024 02:05:31 +0100 Subject: [PATCH 2/2] add ollama to help --- functions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions.py b/functions.py index 348f71d..739b9c0 100644 --- a/functions.py +++ b/functions.py @@ -8,7 +8,10 @@ def processmsg(msg, rcpt): def command(msg, rcpt): if msg.startswith("!help"): - return "chatbot commands: \n" + "!help Show this help page" + response = "chatbot commands: \n" + response += "!help Show this help page" + response += "!ai [message] Ask llama2" + return response elif msg.startswith("!ai"): client = ollama.Client(host='https://ollama.krov.dmz.rs') response = client.chat(model='llama2-uncensored:latest', messages=[{'role':'user','content':f'{msg[4:]}'}])