Compare commits

..

6 Commits

Author SHA1 Message Date
834934fccd Added scraper function 2024-02-06 02:21:53 +01:00
252a7fbdba Merge branch 'master' of ssh://gitea.dmz.rs:2222/Decentrala/chatbot
Conflicts resolved
2024-02-06 02:08:13 +01:00
70b2c9e322 Resolvedconflicts 2024-02-06 02:08:08 +01:00
4bb860b818
add newlines to help 2024-02-06 02:07:47 +01:00
bc2e7422f5
add ollama to help 2024-02-06 02:05:31 +01:00
c2286ae0a6
add ollama command 2024-02-06 02:00:41 +01:00
4 changed files with 15 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
config.ini
venv/
__pycache__

View File

@ -1,3 +1,4 @@
import ollama
import scraper_functions as sf
def processmsg(msg, rcpt):
@ -8,4 +9,12 @@ 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" + "\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'])

View File

@ -1,3 +1,4 @@
slixmpp
ollama
requests
beautifulsoup4

View File

@ -4,6 +4,6 @@ from bs4 import BeautifulSoup
def query_external_website(base_url, query):
page = requests.get(base_url + query)
soup = BeautifulSoup(page.content, "html.parser")
title = soup.select(".mw-page-title-main")[0]
content = soup.find(id="bodyContent").select("p")[2].text
return "\nTITLE: " + title.text + "\n\n" + "CONTENT:" + "\n" + content + "\n\n" + "FULL LINK:\n" + base_url + query
title = soup.find("span", class_="mw-page-title-main").text
content = soup.find(id="mw-content-text").select("p")[2].text
return "\nTITLE:\n" + title + "\n\nCONTENT:\n" + content + "\n\nFULL LINK:\n" + base_url + query