chatbot/functions.py
2024-02-06 02:07:47 +01:00

20 lines
710 B
Python

import ollama
def processmsg(msg, rcpt):
if msg.startswith("!"):
return command(msg, rcpt)
elif "youtube.com/watch" in msg:
return msg.replace("youtube.com", "iv.datura.network")
def command(msg, rcpt):
if msg.startswith("!help"):
response = "chatbot commands:" + "\n"
response += "!help Show this help page" + "\n"
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:]}'}])
return(response['message']['content'])