#OpenAI generating empty strings

70 messages · Page 1 of 1 (latest)

mossy gorge
#

Hello everyone, I'm making a discord bot that allows you to clone any person that you want and it will allow you to talk to them as if you are talking to the person you chose through discord slash commands. I'm working on making it save the past 5 interactions it had with a User in a certain Guild but when I implemented this, it started to generate empty strings which would make JDA error because the discord bot cant send an empty string. Can someone look into this for me? Thanks sm

            CompletionRequest completionRequest = CompletionRequest.builder()
                    .prompt(String.format("As an expert in imitating human conversations, " +
                                    "please respond as %s, the character/personality you are going to clone, " +
                                    "to the following input:%s. %s",
                            SQLManager.getCharacter(event.getGuild()),
                            prompt,
                            message != null ? containsPastMessage : ""))
                    .model("text-davinci-003")
                    .maxTokens(200)
                    .temperature(.8)
                    .stop(Arrays.asList("SAUHNASDFUIJBDNIHASJFBIHDASJKBFGIHSDGBVSHDfv"))
                    .frequencyPenalty(2.0)
                    .presencePenalty(2.0)
                    .build();

//Will be empty SOMETIMES :(
            String response = completionResult.getChoices().get(0).getText();

#

Here is an example of what happens, and sometimes it will happen sooner/later its random honestly

#

It will send the error message when its an empty response

meager field
mossy gorge
meager field
#

print the response in its entirety as the object itself and show us that

mossy gorge
#

Ah ikwym

#

Alr one sec

#

CompletionResult(id=cmpl-7Kyat3iDfCHPDW4vcLqB9cDni1FPk, object=text_completion, created=1685233839, model=text-davinci-003, choices=[CompletionChoice(text=Hey there! I'm doing great, how about you?, index=0, logprobs=null, finish_reason=stop)], usage=Usage(promptTokens=39, completionTokens=14, totalTokens=53))

#

Is this what you mean @meager field

#

if so here is another example

#
As an expert in imitating human conversations, please respond as Kim kardashian, the character/personality you are going to clone, to the following input:hey how are you!?. There is already a conversation going on between you and this user. Try to use the conversation that has already been going on to make the best response to the the prompt given to you by the user.However DO NOT INCLUDE ANY PART OF THE PREVIOUS CONVERSATION IN YOUR REPLY. THE CONVERSATION IS STORED IN DATA AND YOU DO NOT NEED TO REPEAT IT PUT THE RESPONSE!!!OR TALK IN CONVERSATION FORMAT. Here is the conversation
User:hey how are you!?
Kim kardashian:Hey there! I'm doing great, thanks for asking. How about you?


CompletionResult(id=cmpl-7LIJfIp9b3af8q8sJKXa6gHUH22aL, object=text_completion, created=1685309651, model=text-davinci-003, choices=[CompletionChoice(text=, index=0, logprobs=null, finish_reason=stop)], usage=Usage(promptTokens=175, completionTokens=0, totalTokens=175))
meager field
#

But I've also never used Java

mossy gorge
#

i can try to print smth else out

meager field
mossy gorge
#
CompletionRequest(model=text-davinci-003, prompt=As an expert in imitating human conversations, please respond as Kim kardashian, the character/personality you are going to clone, to the following input:what does what mean?. 

, suffix=null, maxTokens=4046, temperature=0.8, topP=null, n=null, stream=null, logprobs=null, echo=null, stop=[ZZZZZZZZZZZZZZZZZZZZZZZZZZ], presencePenalty=2.0, frequencyPenalty=2.0, bestOf=null, logitBias=null, user=null)
#

is this what ur looking for

meager field
#

That's the request. So when you call that request, print whatever the API returns.

mossy gorge
meager field
#

Interesting.

mossy gorge
#

yeah its so annoying

meager field
#

Java is annoying.

mossy gorge
#

my bot is like done its just this stupid bug

meager field
#

OH

#

I see the formatting now. Okay.

mossy gorge
meager field
#

One moment please

mossy gorge
#

kk thanks

meager field
# mossy gorge kk thanks

I need your help with this diagnostic. Is the value of null a built-in value or default in Java?

mossy gorge
#

default

meager field
#

Ok

meager field
# mossy gorge

max_tokens is a value for completion, not completion + prompt. This means that if your completion is more than 51 tokens, it won't complete.

#

Try reducing the maximum tokens.

mossy gorge
#

whats a value you would try

meager field
#

Depends on how much you want to spend. With that model, a value of 3000 would cap you at a $0.06 response.

meager field
#

If you're telling the bot to respond as Kim, and then you include Kim's statement as part of the request, the completion will believe that nothing needs to be completed.

#

You'd be better off using this function with ChatGPT's 3.5 model. Not only is it better at taking instructions, but you can direct it even more in system messages.

mossy gorge
#

does the java openai support it

#

ive tried to use turbo but i got this error and i didnt know exactly what model to use

mossy gorge
meager field
#

I don't know anything about a Java OpenAI wrapper but you can always craft your own POST requests.

meager field
mossy gorge
#

i dont see how that would work

#

for example

#
/talk <Hey how are you>
*respoonse* Hey im good how aboutyourself?

now if i did what you said it would be

User: Hey how are you
Kim kardashian: 

now what if the next prompt the user said was

/talk wait what did you just say?

the bot wouldnt know exactly what was last said because it doesnt save

mossy gorge
meager field
#

Then you need to program in the ability to save. Which is infinitely easier to do with ChatGPT's model, but you can still do it with completions

#

So you would need to add the "conversation" to a value and pass the value.

#

So if you did

Kim kardashian: I'm good, how are you?
User: <new request>
Kim kardashian: ```
#

You need to add your own conversation history functionality for the API. This is the same for any programming language

mossy gorge
#

is that built in with turbo or something? im not sure how i would do that exactly

meager field
#

No, but turbo uses "messages" instead of "prompt" which handles conversation. In ChatCompletions, your post request looks like this:

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [{"role": "user", "content": "Hello!"},
                  "role": "assistant", "content": "Hi there, how are you?"}]
  }'```

As you can see, the messages value holds messages as if they were part of a chat.
mossy gorge
#

i see

#

alright i can play around with this

mossy gorge
#

@meager field well it now works, i think i actually never wanted to die more than implementing this now and im actually sweating and i never want to touch my keyboard every again

#

ty for the help

#

😇

meager field
mossy gorge
#

im literally going to throw up

meager field
#

It's like Gollum with the one ring. You hate and love code.

mossy gorge
#

idk what that is

#

but sure

mossy gorge
#

nd now it doesnt even say like messed up stuff itll say the
"I'm sorry, but I cannot fulfill this request as it goes against my programming to generate inappropriate or offensive language. As an AI language model, I am designed to promote positivity and respect towards all individuals and cultures." message