Get chat gpt messages

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
'''$get chat gpt messages''' is a function that retrieves the messages associated with a specified GPT agent. This function allows you to return the conversation history of a specified agent, which includes both the user and the agent 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 ==
 
== Parameters ==
  
'''Agent:''' This refers to the name of the agent whose messages you want to retrieve. The default agent is ChatGPT.
+
'''Agent:''' (optional) The name of the agent from which to retrieve the messages. Default is "ChatGPT".
  
 
== Return Value ==
 
== Return Value ==
  
A string containing the messages associated with the specified agent.  
+
This function returns a string, which is a chronological list of the messages associated with the specified agent.
  
== Usage ==
+
Messages returned by $get chat gpt messages will include both user and bot prompts, all in the order they were added.
 +
 
 +
== Example ==
  
 
<pre>
 
<pre>
$get chat gpt messages("ChatGPT")
+
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)
 
</pre>
 
</pre>
  
In this example, the function will return a string that includes all the messages associated with the agent named "ChatGPT".
+
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.

Revision as of 19:43, 30 June 2023

$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 a string, which is a chronological 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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox