Extract Object from llm response
Function: Extract Object from LLM Response
This action helps you automatically find and extract structured information (like a list of items, a customer's details, or a product specification) from a text response generated by an AI (Large Language Model). It's especially useful when the AI's response contains extra conversational text around the actual data you need, or when the data is embedded within a code block.
Input,
- LLM Response (Text): The complete text response you received from the AI. This is the text where the action will search for the structured information.
- Data Format (Data Structure): This defines the expected structure of the information you want to extract. It tells the action what kind of "object" or "list of objects" to look for (e.g., a "Product Details" structure with fields like name, price, and description).
Output,
- Result (Object): The extracted structured information, presented as an object or a list of objects that matches the Data Format you specified. This will be stored in a variable named 'RESULT' by default, or a name you choose.
Execution Flow,
Real-Life Examples,
Example 1: Extracting Product Details from a Chatbot Response
Imagine you have a chatbot that provides product information, and you want to automatically pull out the product's name, price, and availability to update your inventory system.
- Inputs:
- LLM Response: "Sure, here are the details for the 'Smartwatch Pro':
json\n\{\"productName\": \"Smartwatch Pro\", \"price\": 199.99, \"inStock\": true, \"features\": [\"Heart Rate Monitor\", \"GPS\", \"Waterproof\"]\}\n. Let me know if you need anything else!" - Data Format: A pre-defined data structure named "ProductDetails" with fields:
productName(Text),price(Number),inStock(True/False),features(List of Text).
- LLM Response: "Sure, here are the details for the 'Smartwatch Pro':
- Result: The
RESULTvariable will contain an object with the product details:This object can then be used to automatically update your product catalog or display information on a product page.\{
"productName": "Smartwatch Pro",
"price": 199.99,
"inStock": true,
"features": ["Heart Rate Monitor", "GPS", "Waterproof"]
\}
Example 2: Getting Customer Feedback from an AI-Summarized Survey
You've used an AI to summarize customer feedback from a survey, and the AI's response includes the key feedback points in a structured format. You want to store this feedback in your customer relationship management (CRM) system.
- Inputs:
- LLM Response: "The customer provided the following feedback: {"customerName": "Alice Smith", "rating": 5, "comment": "Excellent service, very quick response!"} We appreciate their input and will follow up."
- Data Format: A pre-defined data structure named "CustomerFeedback" with fields:
customerName(Text),rating(Number),comment(Text).
- Result: The
RESULTvariable will hold an object:This extracted feedback can be automatically logged into your CRM system for review and action.\{
"customerName": "Alice Smith",
"rating": 5,
"comment": "Excellent service, very quick response!"
\}
Example 3: Parsing a List of Tasks from an AI Assistant
An AI assistant has generated a list of tasks for your team, and you need to import these tasks into your project management tool.
- Inputs:
- LLM Response: "Here is your updated task list for the week: [{"task": "Prepare Q3 Report", "dueDate": "2023-09-30", "priority": "High"}, {"task": "Schedule Team Meeting", "dueDate": "2023-09-25", "priority": "Medium"}] Please confirm these tasks."
- Data Format: A pre-defined data structure named "TaskList" which is an
ARRAYof objects, where each object has fields:task(Text),dueDate(Date),priority(Text).
- Result: The
RESULTvariable will contain a list of task objects:This list can be used to automatically populate your project management system, creating new tasks with their respective details.[
\{
"task": "Prepare Q3 Report",
"dueDate": "2023-09-30",
"priority": "High"
\},
\{
"task": "Schedule Team Meeting",
"dueDate": "2023-09-25",
"priority": "Medium"
\}
]