#GPT not returning anything

88 messages · Page 1 of 1 (latest)

whole lake
#
response = openai.Completion.create(
        engine="text-davinci-002",
        prompt=prompt_text,
        temperature=1,
        max_tokens=300,
        top_p=1,
        frequency_penalty=0.7,
        presence_penalty=0.1,
        stop=["\n"],
    )

won't return anything. and yes I have something as my prompt. is there some error I am missing? I don't get a error printed (python btw)

abstract mango
#

The OpenAI API for JavaScript loads the response asynchronously, so you have to use concurrency to get the result.

whole lake
abstract mango
#

Concurrency is the common method of implementing REST endpoints

whole lake
#

I've changed it to the following and yet it won't work ```py
async def ask(question, chat_log=None):
print("ask")
prompt_text = f'{chat_log}{restart_sequence}: {question}{start_sequence}'
print("about to think")
response = await openai.Completion.create(
engine="text-davinci-003",
prompt=prompt_text,
temperature=1,
max_tokens=300,
top_p=1,
frequency_penalty=0.7,
presence_penalty=0.1,
stop=["\n"],
)
print("about to return")
story = response['choices'][0]['text']
print("return")
return str(story)

abstract mango
#

Ah alright, just didn’t get the context before with the call being in an async function.

whole lake
#

it was a normal function

#

but since you can't await a normal function, I had to turn it into a async function

abstract mango
#

Oh maybe you’re using an engine in that?

#

OpenAI recently deprecated completely the use of engines

whole lake
#

whut

#

that could be my problem

#

but how should I tell openai then what model to use?

abstract mango
#

Use the model parameter

#

Instead of engine

#

Also make sure your node packages are updated

whole lake
#

should be. How can I double-check them?

abstract mango
#

npm-check-updates

#

In the terminal in the root of your project

whole lake
# abstract mango const response = await openai.createCompletion({ model: "text-davinci-003", ...

So just to make this clear. This would be ok?

async def ask(question, chat_log=None):
    print("ask")
    prompt_text = f'{chat_log}{restart_sequence}: {question}{start_sequence}'
    print("about to think")
    response = await openai.Completion.create(
        model="text-davinci-003",
        prompt=prompt_text,
        temperature=1,
        max_tokens=300,
        top_p=1,
        frequency_penalty=0.7,
        presence_penalty=0.1,
        stop=["\n"],
    )
    print("about to return")
    story = response['choices'][0]['text']
    print("return")
    return str(story)
abstract mango
#

Run that command

whole lake
#

nah that isn't a valid command for me

abstract mango
#

Yeah update your packages and make sure they’re up to date

#

I assume you’re instantiating the openai object properly with a proper config object and such.

whole lake
abstract mango
whole lake
#

aight

#

thanks for your help so far

whole lake
#

@abstract mango u there?

abstract mango
#

Oh yeah sorry, give me another few minutes here

abstract mango
abstract mango
#

Seeing that they are variables set outside of the main function

whole lake
#

don't worry about them.

abstract mango
#

Fair enough

whole lake
#

they are set okay.

abstract mango
#

It's all good

whole lake
#

they are defined by my bots name and the user input. which again are stored in my DB so the AI knows what she should say and what the user said

#

sorry my english isn't on point today

abstract mango
#

No worries

whole lake
#

well I'm still clueless what could be causing my problems

abstract mango
#

Remove that.

whole lake
#

shouldn't be. I never changed that since I build that AI

#

you know that stop prevents the bot from generating new lines with tokes aka. blasting the heck out of my wallet?

abstract mango
#

Though it seems like it won't generate any text with the stop parameter

#

Oh also remove the await before the openai call.

whole lake
#

here is a quick example of how stuff is stored in my DB (it's in german so if you want I can quickly translate that): ```py
"\nUser: Wie geht's dir Rachel": "\n\nRachel: Mir geht's gut. Und dir?\n",

abstract mango
#

Yeah it was late night last night, so I mistakingly thought it was JS :P

#

Anyways

abstract mango
#

Yeah

whole lake
abstract mango
#

Now yeah, it's Python

#

I'm assuming you're using asyncio?

whole lake
#

mhm

#

but what has ayncio to do with that?

abstract mango
#

Then keep the async for the def, remove the await for the openai call

#

Just how the code is implemented mainly.

whole lake
#

alright

abstract mango
#

Yeah for some reason it's returning nothing on my end, but glad you got your code working

whole lake
#

that's the code now: ```py
async def ask(question, chat_log=None):
prompt_text = f'{chat_log}{restart_sequence} {question}{start_sequence}'
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt_text,
temperature=1,
max_tokens=300,
top_p=1,
frequency_penalty=0.7,
presence_penalty=0.1,
stop=["\n"],
)
story = response['choices'][0]['text']
return str(story)


and the call of the function: ```py
thought = await message.channel.send(await ask(question=msg_content, chat_log=chat_log),
                                                     reference=message)
whole lake
abstract mango
#
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "text": ""
    }
  ],
  "created": 1669836117,
  "id": "cmpl-6IMwXlZvF8ulKraj5cgBtzoJcpEp0",
  "model": "text-davinci-003",
  "object": "text_completion",
  "usage": {
    "prompt_tokens": 26,
    "total_tokens": 26
  }
}
#

This is the JSON response I get

#

So it's stopping right as when it starts responding

whole lake
#

that's weird

abstract mango
# whole lake that's weird

I'd honestly say best route to take is to create a fine tuned model with some data you make that's formatted properly.

#

That way the model has a better chance of responding with what you need.

whole lake
#

well yes and no

#

I want my bot to learn by herself. hence why I have a DB hooked to her where she constantly saves her answers to improve herself. Kinda like machine learning.

#

I only gave her a structure of what she is
The rest is up to her to generate

abstract mango
#

Oh yeah, OpenAI does have the whole fine tune feature set, which is great from my own experience.

whole lake
#

agreed

abstract mango