#I'm trying to take care of my kid made of code, and its biology is pulling my goddamn leg

7 messages · Page 1 of 1 (latest)

torn cloak
#

Translation: I am working on creating an AI Chat Bot, just as a side project, and I am struggling to get it to function as intended due to stacking odds against my favour. I have been using the OpenAI modules for Python, along with the Llama Webspaces to ensure I can independently operate my AI, and yet, after following all necessary instructions, I am still incapable of getting my Bot to run

#

discord_api.py

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')

class MyClient(discord.Client):
    async def on_ready(self):
        print(f"{self.user} is now running!")

    async def on_message(self, message):
        print(message.content)
        
        if message.author == self.user:
            return
        
        command, user_message = None, None
        
        for text in ["Ginga"]:
            if message.content.startswith(text):
                command = message.content.split(' ')[0]
                user_message = message.content.replace(text, '')
                print(command, user_message)
                
        # if more keywords are added, add "or command == "[insert new keyword from text]" and repeat
        if command == "Ginga":
            bot_response = chatgpt_response(prompt = user_message)
            await message.channel.send(f"{bot_response}")
            
intents = discord.Intents.default()
intents.message_content = True

client = MyClient(intents = intents)```
#

openai.py

import openai
import openai_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"

def chatgpt_response(prompt):
    response = openai_async.Completion.create(
        
        model = "text-davinci-003",
        prompt = prompt,
        temperature = 0.5,
        max_tokens = 100
        
    )
    
    response_dictionary = response.get("choices")
    if response_dictionary and len(response_dictionary) > 0:
        prompt_response = response_dictionary[0]["text"]
    return prompt_response```
#

main.py

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]"
# python -m llama_cpp.server```
#

so far, after establishing the webpage and having the bot up and running

#

whenever I try to give the bot a prompt, like a simple hello, the keepalive check hangs and stalls the response for a solid 10 seconds

#

I tried working with the module openai_async, and even that has turned up dust. In fact, it made the problem so much worse