Page 1 of 1

Open AI topic when using Freeform Text Input

Posted: Thu Jul 13, 2023 5:45 pm
by nathanj
Hi Tony,

Sorry to bother you but there is something I can not figure out with the Open AI integration. When a player submits a reply with FreeformTextInputConversation, RuntimeAIConversationSettings detects the Input with

Code: Select all

public StandardUIInputField ChatInputField => chatInputField;
but I can not figure out what this is triggering to prompt a response.
What is happening is even though I am changing the topic with an external command, the original topic is always restated through the AIs text.
So for example, the RuntimeAIConversation Topic starts with "Welcome the player" and then after the player responds the topic is changed to "Ask the player..." but every time the second conversation starts it welcomes the player and then asks the player. It's like there is a list of Topics that get cached and recalled in every conversation.

If this makes sense, can you think of a way around this?

Thank you,
Nathan

Re: Open AI topic when using Freeform Text Input

Posted: Thu Jul 13, 2023 6:35 pm
by nathanj
I feel like if I could not trigger a response right away after submitting a response and then calling RuntimeAIConversation.Play it might behave like I am hoping?

Re: Open AI topic when using Freeform Text Input

Posted: Thu Jul 13, 2023 7:18 pm
by Tony Li
Hi Nathan,

Are you setting the RuntimeAIConversation component's Topic property?

You can temporarily set the Dialogue Manager's Debug Level to Info. This will log what prompts it's sending. The example Runtime Demo scene's prompt is "about acquiring the launch codes." When I played the scene and clicked the Text Input Conversation button, the Console logged:

Dialogue System: Sending to OpenAI: The Player controls a soldier sent to intercept the evil space emperor's launch codes to prevent him from attacking your planet. Private Hart is a kind-hearted soldier who offers the quest to hack the emperor's computer to get the launch codes. Write an initial line of dialogue spoken by Private Hart to Player about acquiring the launch codes.
Dialogue System: Received from OpenAI: "Listen up, soldier. We've got a mission to save our planet. I need someone with hacking skills to get us those launch codes. Think you're up for it?"

Then I ended the conversation but didn't exit play mode. I set the Topic in the inspector to "about the meaning of life" (which is the same as setting the Topic property in C#) and clicked the button again. The Console logged:

Dialogue System: Sending to OpenAI: The Player controls a soldier sent to intercept the evil space emperor's launch codes to prevent him from attacking your planet. Private Hart is a kind-hearted soldier who offers the quest to hack the emperor's computer to get the launch codes. Write an initial line of dialogue spoken by Private Hart to Player about the meaning of life.
Dialogue System: Received from OpenAI: "Hey, soldier. While we're on this mission to save our planet, have you ever pondered the meaning of life?"

Re: Open AI topic when using Freeform Text Input

Posted: Fri Jul 14, 2023 12:39 pm
by nathanj
Ok, this helps alot. Thanks for pointing out the debug too again :oops: It really helped with understanding how the result is determined.

I found that if I add all of my player's conversations to a single variable and then use a different AI character to summarize variable value I can get the result that I need. Its a little convoluted but it works.

Thank you again,
Nathan

Re: Open AI topic when using Freeform Text Input

Posted: Fri Jul 14, 2023 12:56 pm
by Tony Li
One thing I've found with this is that there's definitely an art to writing prompts, especially when using GPT-3.5 since it's limited to 4096 tokens. Fortunately if your conversations are long or complex, you can now switch to the GPT-3.5-16K model for 4x the tokens.

Re: Open AI topic when using Freeform Text Input

Posted: Fri Jul 14, 2023 1:25 pm
by nathanj
That is also really helpful to know, thanks again. Yeah, I'm slowly learning how to refine my prompts.