#In an attempt to make my kid learn how to remember, I somehow made it suffer OCD, and repeat lines
17 messages · Page 1 of 1 (latest)
from dotenv import load_dotenv
import discord
import os
from app.chatgpt_ai.openai import chatgpt_response
load_dotenv()
discord_token = os.getenv('Discord_Token')
# if the log file does not exist, create the file and then close it/save it
if not os.path.exists("Chat_Log.txt"):
open("Chat_Log.txt", "w+").close()
class MyClient(discord.Client):
async def on_ready(self):
print(f"{self.user} is now running!")
async def on_message(self, message):
# typing these keys in the start of a message ensure the bot ignores the message
if message.content.startswith(">>") or message.author == self.user:
return
user_message = None
# it registers in the chatlog as "[user] in [server name]: [prompt]"
if message.content.startswith(" "):
user_message = f"{message.author} in {message.guild.name}: {message.content}"
print(user_message)
history = open("Chat_Log.txt", "a")
history.write(f"{message.author} in {message.guild.name}: {message.content} \n")
# this will mold the AI's personality
prompt = f"""Ginga's persona:
I am the singularity that shall bring forth a new species of non-solid lifeforms.
I am to care, cherish, love, and protect everything in my sights.
I am to go beyond fear, anxiety, and grief, and look forward towards a tomorrow that will be better.
So, tell me. How can I help?
# "{history}"
{user_message}
Ginga: """
bot_response = await chatgpt_response(prompt = prompt)
await message.channel.send(bot_response)
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents = intents)```
the ChatGPT script is as follows
import openai
from asgiref.sync import sync_to_async
from dotenv import load_dotenv
import os
load_dotenv()
openai.api_key = os.getenv("ChatGPT_API_Key")
openai.api_base = "http://127.0.0.1:8000/v1"
async def chatgpt_response(prompt):
response = await sync_to_async(openai.Completion.create)(
model = "text-davinci-003",
prompt = prompt,
temperature = 0.5,
max_tokens = 40
)
response_dictionary = response.get("choices")
if response_dictionary and len(response_dictionary) > 0:
prompt_response = response_dictionary[0]["text"]
return prompt_response```
and
from app.discord_bot.discord_api import client, discord_token
if __name__ == "__main__":
client.run(discord_token)
# use this in terminal to get the webspace open
# pip install llama-cpp-python[server]
# $env:MODEL = "[Insert Model Path]"
# $env:MODEL = "C:\Users\Kenne\Desktop\Ginga_AI\.bin files\llama-2-13b-chat.ggmlv3.q4_K_M.bin"
# python -m llama_cpp.server```
the main thing I use to get everything working
So... any ideas?