2

I used Python to access the OpenAI API, then used discord.py to integrate it into a Discord bot. My command looks like this:

@bot.command()
async def chat(ctx, *, input: str):
    openai.api_key = os.getenv(envName)
    
    async with ctx.channel.typing():
        response = openai.Completion.create(
                    engine="text-davinci-003",  # latest model (the one used for GPT-3)
                    prompt=input,
                    temperature=random.randrange(50, 90) / 100,
                    max_tokens=1000,
                    top_p=1,
                    frequency_penalty=0,
                    presence_penalty=0,
                    timeout=10
                )

        output = response.choices[0].text

    await ctx.reply(output)

The command works properly as intended. I give it an input, and it gives me a proper output.

However, I recently discovered that for a simple input such as "hi", it gives me some gibberish output. Moreover, this output is completely different for each time.

Please refer to the images below for its output.

Try 1: Try 1

Try 2: Try 2

Try 3: Try 3


Note that this command works completely fine for any other queries: for example,

Correct response: Print "hello world" (responded correctly)

and another one: Wrote a speech

Strangely, it gives a normal response for "hello" also. "hello" query


What could be the reason why it responds improperly for a simple "hi" query?

J Muzhen
  • 339
  • 1
  • 10
  • For what I get, the AI takes the prompt to generate an answer. If "hello" is obvious as a salutation, "hi", or "HI" have a lot of different meanings and it's possible it picks a random one to return something. Also, you play with temperature. Close to 0, answers are "well defined", but close to 1 it rolls "more creative" answers. Then, you also have to pick a top_p. If you go for temperature=0.1 and top_p = 0.1, it is possible results would be more "equals" but if it picks 0.9 and 1 respectively, I bet results differ a lot. – pluckplk Dec 07 '22 at 11:35

0 Answers0