ChatGPT Extension for Kodular Creator: A Comprehensive Guide
The ChatGPT
extension is a versatile tool designed for use with the OpenAI’s ChatGPT API. This guide provides a detailed overview of its public methods, parameters, and the expected outputs.
Public Methods
1. jsonDecode
- Description: Extracts a value from a JSON text based on a specified key.
-
Parameters:
-
jsonText
(Text): The JSON text to be parsed. -
key
(Text): The key for which the value is to be extracted.
-
- Returns: A Text representing the value associated with the key, or an error message if the key is not found.
2. SendPrompt
- Description: Sends a prompt to ChatGPT and triggers a response.
-
Parameters:
-
prompt
(Text): The prompt to send to ChatGPT. -
model
(Text): The model of ChatGPT to use. -
systemMsg
(Text): System message to be included. -
temperature
(Number): Determines the randomness in the response. -
apiKey
(Text): Your OpenAI API key.
-
-
Returns: Triggers
ResponseReceived
event with the response text orReportError
if none.
3. GenerateImage
- Description: Generates an image based on a given prompt.
-
Parameters:
-
prompt
(Text): The prompt based on which the image is generated. -
numberOfImages
(Number): The number of images to generate. -
apiKey
(Text): Your OpenAI API key. -
model
(DallEModel
): The DALL-E model to use. -
size
(ImageSize
): The size of the generated image.
-
-
Returns: Triggers
ImageGenerationCompleted
event with image data orReportError
if none.
4. CreateThread
- Description: Creates a new thread for message interactions.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key.
-
-
Returns: Triggers
ThreadCreated
event with thread data orReportError
if none.
5. RetrieveThread
- Description: Retrieves an existing thread by its ID.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key. -
threadId
(Text): The ID of the thread to retrieve.
-
-
Returns: Triggers
ThreadRetrieved
event with thread data orReportError
if none.
6. ModifyThread
- Description: Modifies metadata of an existing thread.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key. -
threadId
(Text): The ID of the thread to modify. -
metadata
(Text): New metadata for the thread.
-
-
Returns: Triggers
ThreadModified
event with updated thread data orReportError
if none.
7. DeleteThread
- Description: Deletes an existing thread.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key. -
threadId
(Text): The ID of the thread to delete.
-
-
Returns: Triggers
ThreadDeleted
event with deletion status orReportError
if none.
8. CreateMessage
- Description: Creates a message in a specified thread.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key. -
threadId
(Text): The ID of the thread where the message is to be created. -
messageContent
(Text): The content of the message.
-
-
Returns: Triggers
MessageCreated
event with message data orReportError
if none.
9. RetrieveMessage
- Description: Retrieves a specific message from a thread.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key. -
threadId
(Text): The ID of the thread containing the message. -
messageId
(Text): The ID of the message to retrieve.
-
-
Returns: Triggers
MessageRetrieved
event with message data orReportError
if none.
10. ModifyMessage
- Description: Modifies metadata of a message in a thread.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key. -
threadId
(Text): The ID of the thread containing the message. -
messageId
(Text): The ID of the message to modify. -
metadata
(Text): New metadata for the message.
-
-
Returns: Triggers
MessageModified
event with updated message data
or ReportError
if none.
11. ListMessages
- Description: Lists messages in a specified thread.
-
Parameters:
-
apiKey
(Text): Your OpenAI API key. -
threadId
(Text): The ID of the thread whose messages are to be listed.
-
-
Returns: Triggers
MessagesListed
event with a list of messages orReportError
if none.
12. ShowNativeAudioPlayerDialog
- Description: Shows a dialog with a native audio player.
-
Parameters:
-
title
(Text): The title of the dialog. -
audioFilePath
(Text): The file path of the audio. -
titleColor
(Number): Color of the dialog title. -
titleBackgroundColor
(Number): Background color of the title. -
dialogBackgroundColor
(Number): Background color of the dialog.
-
- Returns: A dialog with controls to play and pause the audio.
13. ShowTextInputDialog
- Description: Shows a dialog with a text input.
- Parameters: Various parameters to customize the dialog appearance and behavior.
-
Returns: Triggers
TextEntered
event with the entered text.
14. ShowListDialog
- Description: Displays a dialog with a list of selectable items.
- Parameters: Various parameters to customize the dialog and list items.
-
Returns: Triggers
ListItemSelected
event with the selected item.
15. GenerateSpeech
- Description: Generates speech from text.
- Parameters: Includes parameters for text, voice model, audio quality, and format.
-
Returns: Triggers
SpeechGenerated
event with the file path of the generated speech.
16. SendVisionRequest
(NEW)
-
Description: Sends a vision request with an image URL or base64 data to a GPT model, allowing the AI to analyze the image and respond based on the provided text prompt.
-
Parameters:
-
maxTokens
(Number): Maximum number of tokens in the response. -
text
(Text): The accompanying text prompt. -
gptModel
(VisionModel
): The model to be used for processing. -
imageData
(Text): Image URL or base64-encoded image data. -
detail
(DetailParameter
): Image detail level for the AI to process. -
apiKey
(Text): Your OpenAI API key.
-
-
Returns: Triggers
VisionResponseReceived
event with the response orReportError
if an error occurs. -
How it works: The method sends an HTTP POST request to OpenAI’s API. The image and text prompt are sent together, and the AI responds by analyzing the image. The response is then passed to the
VisionResponseReceived
event or an error message is reported.
Events
The extension triggers various events corresponding to the successful execution of the methods, such as ResponseReceived
, ImageGenerationCompleted
, ThreadCreated
, MessageCreated
, VisionResponseReceived
and more, providing necessary data or status updates.
This guide covers the key functionalities provided by the ChatGPT
extension for Kodular, offering a wide range of capabilities from interacting with ChatGPT, image generation, thread and message management, to audio functionalities.
Blocks
AIX files:
-
Version 6: com.bosonshiggs.chatgpt.aix (55.4 KB)
-
Version 7 (GPT Vision): com.bosonshiggs.chatgpt.aix (62.3 KB)
GitHub: GitHub - iagolirapasssos/chatGPTAndDallE: The ChatGPT extension for MIT App Inventor now includes support for handling threads and messages within threads, providing a more dynamic and interactive experience with the OpenAI API.
AIA file (new)
ChatGPTAndDallE.aia (349.6 KB)
DEMO
Click here and buy me a coffee.
If you’d like to help us in our mission, you can donate to us to keep this budget-friendly work going.
Donor support
- : Telegram
- GitHub - click here