Extract XML from llm response
Function: Extract XML from AI Assistant's Reply
This action helps you automatically find and extract XML formatted text from a longer response provided by an AI assistant (Large Language Model - LLM). This is useful when an AI assistant generates a response that includes structured data in XML format, along with other conversational text.
Input
- LLM Response (A piece of text): This is the full text generated by the AI assistant, which might contain the XML you want to extract. This input is required.
Output
- Result (A piece of text): This is the variable where the extracted XML text will be stored. By default, it will be named "RESULT", but you can choose a different name for your variable.
Execution Flow
Real-Life Examples
Here are some examples of how you can use the "Extract XML from AI Assistant's Reply" action:
Example 1: Extracting Product Details from a Chatbot Response
Imagine you're building an e-commerce support chatbot. A customer asks for details about a product, and your AI assistant responds with a mix of conversational text and structured product information.
- Inputs:
- LLM Response: "Certainly! Here are the details for the 'Smartwatch Pro':
xml<product><name>Smartwatch Pro</name><sku>SWP-2023</sku><price>199.99</price><features><feature>Heart Rate Monitor</feature><feature>GPS</feature><feature>Waterproof</feature></features></product>Let me know if you need anything else!"
- LLM Response: "Certainly! Here are the details for the 'Smartwatch Pro':
- Result: The action will extract the XML block and store it in a variable named
ProductDetailsXML.ProductDetailsXMLwill contain:<product>
<name>Smartwatch Pro</name>
<sku>SWP-2023</sku>
<price>199.99</price>
<features>
<feature>Heart Rate Monitor</feature>
<feature>GPS</feature>
<feature>Waterproof</feature>
</features>
</product>
Example 2: Processing a Configuration Update from an AI Assistant
You're using an AI assistant to help manage system configurations. You ask it to generate a configuration snippet, and it provides it within a larger explanation.
- Inputs:
- LLM Response: "I've generated the requested configuration for the new user role. Please review and apply it carefully.
xml<config><role name='Admin'><permissions><permission>read</permission><permission>write</permission></permissions></role></config>This should grant the necessary access."
- LLM Response: "I've generated the requested configuration for the new user role. Please review and apply it carefully.
- Result: The action will find and store the configuration XML in a variable named
NewRoleConfig.NewRoleConfigwill contain:<config>
<role name='Admin'>
<permissions>
<permission>read</permission>
<permission>write</permission>
</permissions>
</role>
</config>
Example 3: Extracting a Data Report from an AI-Generated Summary
Your AI assistant summarizes daily sales data and includes a detailed XML report for further processing.
- Inputs:
- LLM Response: "Daily sales summary: Overall, sales were up by 5% today. Here is the detailed breakdown:
xml<report date='2023-10-27'><totalSales>15000</totalSales><itemsSold>300</itemsSold><topProduct>Widget X</topProduct></report>We should focus on promoting Widget Y next."
- LLM Response: "Daily sales summary: Overall, sales were up by 5% today. Here is the detailed breakdown:
- Result: The action will extract the report XML and save it to a variable named
DailySalesReport.DailySalesReportwill contain:<report date='2023-10-27'>
<totalSales>15000</totalSales>
<itemsSold>300</itemsSold>
<topProduct>Widget X</topProduct>
</report>