chatbot/functions.py

17 lines
594 B
Python
Raw Normal View History

2024-02-06 01:00:41 +00:00
import ollama
2024-02-05 23:40:23 +00:00
def processmsg(msg, rcpt):
2024-02-06 00:03:54 +00:00
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"):
return "chatbot commands: \n" + "!help Show this help page"
2024-02-06 01:00:41 +00:00
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'])