Skip to main content

Overview

Conversations consist of a messageThread which contains dialogues. They each have a role and content property.:
TermDescription
Message ThreadA list/array of objects that comprise the conversation; each object is a dialogue
ConversationSame as message thread
DialogueEach object is a Dialogue that has a role and a content property
RoleWill be one of user, assistant, or system.
ContentA String representation of the conversation
AgentA Canopy bot that can take actions

Models

We current support the following models:
ModelOverview
gpt-3.5-turboUltra low latency, not good for action calling or applications which require complex logic
gpt-4-turbo~ +300 ms of latency. Good for agent like behaviour and action calling

CRUD conversations

You can run the CRUD operations:
Operation IDDescription
ReadConversationSends the messageThread to the client
AppendDialogueAdds a dialogue to the messageThread
UpdateDialogueUpdates a dialogue in the messageThread
DeleteDialogueDeletes a dialogue in the messageThread

Read Conversation

You can submit the ReadConversation event which will return the entire messageThread.

const canopy  = new Canopy ({ ... }) 
const { messageThread }  = await canopy.ReadConversation()
The response will be something like:
{
    success: true,
    timestamp: 1623346800,
    messageThread: [
         {
            role: "system",
            content: "You are a friendly bot"
        },
        {
            role: "user",
            content: "Hello"
        },
        {
            role: "assistant",
            content: "Hi there!"
        }
        ...
    ]
}
You can use ReadConversation to get the entire message thread, and parse and do what you want with it.

Append Dialogue

You can submit the AppendDialogue event which will, add the dialogue you provide to the end of the messageThread, and return the entire messageThread.

const canopy  = new Canopy ({ ... }) 
const { messageThread }  = await canopy.AppendDialogue({
    role: "system",
    content: "Here is information from the database:..."
})
The response will be the message thread with the appended dialogue. You can use AppendDialogue to add a message to the conversation. For example,if you were retrieving data from a database you could pass it as information in a system message. If you were

Update Dialogue

You can submit the UpdateDialogue event which will return the entire message thread.

const canopy  = new Canopy ({ ... }) 
const { messageThread }  = await canopy.UpdateDialogue({
    role: "system",
    content: "Here is information from the database:...", 
    dialogueIndex:4 // the index in the message thread array of this dialogue
})
The response will be the message thread with the appended dialogue. You can use UpdateDialogue to change a message in the conversation. For example, if you wanted to fill in information about the user in a system message as you learn it.

Delete Dialogue

You can submit the DeleteDialogue event which will return the entire message thread.

const canopy  = new Canopy ({ ... }) 
const { messageThread }  = await canopy.DeleteDialogue({
    dialogueIndex:4 // the index in the message thread array of this dialogue
})
The response will be the message thread with the appended dialogue.