initial commit

This commit is contained in:
zongor 2023-04-11 15:35:23 -04:00
commit e73c1978aa
4 changed files with 43 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
models/

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# marx-bot
A llama.cpp chatbot which will answer questions on various topics as if it were karl marx.

35
marx.py Normal file
View File

@ -0,0 +1,35 @@
import os
import discord
from llama_cpp import Llama
from dotenv import load_dotenv
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if f"""<@{client.user.id}>""" in message.content:
question = f"""Text transcript of a never ending dialog, where ${USER_NAME} interacts with Karl Marx.
Karl is helpful, kind, honest, friendly, good at writing and never fails to answer ${USER_NAME}s requests immediately and with details and precision.
There are no annotations like (30 seconds passed...) or (to himself), just what ${USER_NAME} and Karl say aloud to each other.
The dialog lasts for years, the entirety of it is shared below. It's 10000 pages long.
User: What is Communism?
Karl: Communism is the doctrine of the conditions of the liberation of the proletariat.
User: {message.content}"""
await message.channel.send(llm(question, max_tokens=256, stop=["User:"], echo=True)["choices"][0]["text"][len(question):])
load_dotenv()
llm = Llama(model_path="./models/7B/ggml-model-q4_0.bin")
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
client.run(os.environ.get("DISCORD_TOKEN"))

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
llama-cpp-python
langchain
discord.py
python-dotenv