Get chat gpt messages
$get chat gpt messages is a function that returns the messages associated with the specified agent.
This function enables users to retrieve and view the conversation history of a specified chat GPT agent. It shows both bot and user messages in chronological order.
Parameters
Agent: (optional) The name of the agent from which to retrieve the messages. Default is "ChatGPT".
Return Value
This function returns an object in yaml format, with a list of the messages associated with the specified agent.
Messages returned by $get chat gpt messages will include both user and bot prompts, all in the order they were added.
Example
config openai("your api key here") create chat gpt agent("FoodBot", "You are FoodBot, an AI designed to offer food and nutrition advice.", "gpt-4") add user message("What should I eat for dinner?", "FoodBot") set(#agent messages, $get chat gpt messages("FoodBot"), "Global") ui text box(#agent messages)
Remember to swap "your api key here" with your actual API key.
This script first creates a chat bot named "FoodBot" who offers food and nutrition advice, then adds a user message querying about dinner options. Then, it retrieves the messages from the FoodBot agent and displays them in a textbox. The returned messages will be either empty or include the added user message, depending on whether any other messages have been added to the conversation.