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
ui console view config openai("your api key here") set(#first prompt,"Hey, I have some questions about tacos. Can I ask them?","Local") set(#first response,$chat gpt response(#first prompt,"ChatGPT"),"Local") set(#second prompt,"What\'s the best salsa to use?","Local") set(#second response,$chat gpt response(#second prompt,"ChatGPT"),"Local") log($get chat gpt messages("ChatGPT"))
Remember to swap "your api key here" with your actual API key.
This script will simulate a conversation with ChatGPT. It will not log the conversation as it happens, but at the end, it will log the entire conversation returned by $get chat gpt messages
The responses from ChatGPT will look different every time, but the output of this script might look something like this:
- role: 'system' content: 'You are a helpful assistant.' - role: 'user' content: 'Hey, I have some questions about tacos. Can I ask them?' - role: 'assistant' content: 'Of course! I''d be happy to help answer your questions about tacos. What would you like to know?' - role: 'user' content: 'What''s the best salsa to use?' - role: 'assistant' content: "The best salsa to use can vary depending on personal taste preferences. Some popular options include red salsa (salsa roja), green salsa (salsa verde), and pico de gallo. \n'\n'Red salsa is typically made with tomatoes, chili peppers, onions, and garlic. It can range from mild to spicy, depending on the type and amount of chili peppers used.\n'\n'Green salsa is made with tomatillos, chili peppers, onions, cilantro, and sometimes garlic. It has a tangy and slightly tart flavor.\n'\n'Pico de gallo is a chunky salsa made with tomatoes, onions, cilantro, chili peppers, and lime juice. It is known for its fresh and vibrant taste.\n'\n'Ultimately, the best salsa for you will depend on your personal preference and the type of tacos you are making. Feel free to explore different varieties and adjust the spiciness level to suit your taste buds."