Retool AI actions
Learn about AI actions to write instructions for AI models.
The Retool AI resource enables you to write queries that instruct AI models to perform different actions:
- Text actions to generate, analyze, and classify text.
- Chat actions to generate responses based on message history.
- Document actions to extract text from PDF documents for use with AI Actions.
- Image actions to generate images based on the provided input.
Text actions
Use Text actions to generate and analyze text content. You provide an instruction and select the model to use.
The response is made available on the data
query property. Rather than waiting until the full response is generated, Retool receives the response stream. This allows the AI model to immediately respond so you can see the response appear in real time.
Generate text
The Generate text action generates text-based content from the input instructions. This is useful if you need some initial content or sample data. For example, you can generate a product description:
- Instruction
- Result
Write a creative product description for a mechanical keyboard named VelocityX Pro, with the keywords "fast responsiveness", "ergonomic", "gaming-optimized" for a software developer who enjoys gaming, and describe the benefits of this product in 100 words.
Introducing the VelocityX Pro Mechanical Keyboard: a winning blend of performance and comfort, expressly designed for the discerning software developer and gaming enthusiast. This marvel of engineering offers lightning-fast responsiveness, delivering an unparalleled key-press experience. Every keystroke is smooth, satisfying and immediate, powering your code-writing and gaming sessions alike. The VelocityX Pro is also ergonomic, thoughtfully crafted to alleviate strain during long coding marathons or intense gaming battles. This gaming-optimized key titan ensures elevated accuracy and speed, designed to keep pace with your agile mind. Finally, the VelocityX Pro suits your dual passion for code and gaming, becoming your ultimate tool for victory.
Summarize text
The Summarize text action generates a summary of the input text. For example, you can provide the text from a blog post and generate a concise summary:
- Instruction
- Result
Retool blog post:
Retool started six years ago as a frontend builder for internal tools. Since we launched, we’ve worked with tens of thousands of companies across every vertical—from two-person startups all the way to Fortune 10s. We focused on making it as fast as possible for developers to build internal apps so that they don’t have to start from scratch to build the same patterns of admin panels, CRUD apps, frontends for APIs, automations, etc.[...]
Retool, a frontend builder for internal tools, is introducing new products aimed at also supporting external use cases. The new offerings, Retool Portals and Retool Embed, were designed to help developers create dashboards, workflows and features for external users such as contractors, vendors, partners, or chosen customers. These external users often have close relationships with the company but aren't employed by it. The new tools will allow companies to simplify processes by automating many tasks that are typically done manually. These features are now available in Business and Enterprise plans.
Classify text
The Classify text action analyzes the input text and classifies it based on the specified labels. This can be useful if you need to perform sentiment analysis or categorize customer requests in some way.
- Instruction
- Result
I was pleasantly surprised by the water bottle's elegant design and excellent insulation, which kept my water cool for an extended period.
Classification labels: positive
, negative
, neutral
{
"data": "positive"
}
Extract entity from text
The Extract entity from text action analyzes the input text and identifies information based on the specified entities. For example, you can extract the product
name and Return address
entities from the following message:
- Instruction
- Result
Dear Mandy,
Your return request for the product, LunarStride Pro, has been declined due to not meeting the required condition for acceptance. We will be shipping this back to 1234 Elm Street, Springfield, CI 56789.
{
"Product": "LunarStride Pro",
"Return address": "1234 Elm Street, Springfield, CI 56789"
}
Chat actions
Use Chat actions to generate message responses based on context from the conversation history and any additional provided data. The Chat component for web apps has built-in support and automatically creates an AI Action query to generate chat responses.
Generate chat response
The Generate chat response action can respond to conversations with users based on the messages previously sent. You can use this action to create an AI chatbot on Retool.
The Message history requires a JSON array of objects with the following properties:
Property | Description |
---|---|
role | The participant in the conversation. Either user for the participant sending messages (i.e., the user) or assistant for the participant responding to messages (i.e., the AI responses). |
[
{
"role": "user",
"content" "hello"
},
{
"role": "assistant",
"content" "hello"
},
]
Document actions
Document actions are only available in Retool apps.
Use Document actions to parse and analyze text from documents you upload or are available in a data store, such as Amazon S3.
Convert document to text
The Convert document to text action analyzes the contents of a file and returns the text it contains. You can connect the action to a File Input component or reference a file using {{ }}
notation, such as a file retrieved from a data store.
The AI model processes the document, extracts the text, and returns it in the response.
Image actions
Use Image actions to generate images based on the provided input.
Generate image
The Generate image action produces images based on the input prompt, then returns a base64-encoded PNG image. This can be used as the value for an Image component or downloaded using utils.DownloadFile().
- Instruction
- Result
A close up, studio photographic portrait of a white siamese cat that looks curious, backlit ears.