Page 1 of 1

DS and OpenAI DS in same conversation

Posted: Fri Jun 07, 2024 1:56 am
by nathanj
Hi Again, Tony

This question is about the Open AI addon.

Is it possible to integrate the OpenAI responses, I'm thinking freeform text, into an existing conversation tree?

Basically, I would like to have two options from a conversation. A is the assigning of a quest through standard Dialogue System and the other branch of the conversation would be a joke generated in runtime through the AI addon.

My only experience with the Open AI addon is a very specific use case that the demo project provided a perfect template to build from. But now I am trying to get a hybrid usage with both systems.

Is this possible?

As always, thank you again.
Nathan

Re: DS and OpenAI DS in same conversation

Posted: Fri Jun 07, 2024 8:39 am
by Tony Li
Hi Nathan,

It takes a little bit of scripting. Write a method that:

1. Records the current conversation title and entry ID.
2. Stops the current conversation.
3. Starts the OpenAI conversation.
4. Hooks into DialogueManager.instance.conversationEnded to know when the OpenAI conversation is done.
5. Resumes the previous conversation.

Then call this method from your standard conversation.

Code: Select all

private string conversationTitle;
private int entryID;
private Transform actor, conversant;

void TellJoke()
{
    conversationTitle = DialogueManager.lastConversationStarted;
    entryID = DialogueManager.currentConversationState.subtitle.dialogueEntry.id;
    actor = DialogueManager.currentActor;
    conversant = DialogueManager.currentConversant;
    DialogueManager.StopConversation();
    DialogueManager.instance.conversationEnded += ResumePreviousConversation;
    yourRuntimeAIConversation.Play();
}

void ResumePreviousConversation(Transform actor)
{
    DialogueManager.StartConversation(conversationTitle, actor, conversant, entryID);
}