cancel
Showing results for 
Search instead for 
Did you mean: 

GenAI App Builder Getting Started Series: Part 2 - Purchase Order Processing

RogerSramkoski
Employee
Employee

👋 Welcome!

Hello everyone and welcome to our second guide in the GenAI App Builder Getting Started Series! First things first, GenAI App Builder is now generally available for all customers to purchase or test in SnapLabs. If you are a customer or partner who wants access to SnapLabs, please reach out to your Customer Success Manager and they can grant you access. If you are not yet a customer, you can check out our GenAI App Builder videos then when you’re ready to take the next step, request a demo with our sales team!

🤔 What is GenAI App Builder?

If you’re coming here from Part 1, you may notice that GenAI Builder is now GenAI App Builder. Thank you to our customers who shared feedback on how we could improve the name to better align with the purpose. The original name had led to some confusion that its purpose was to train LLMs.  

📑 Purchase Order Processing Example

In this example we will demonstrate how to use GenAI in a SnapLogic Pipeline to act like a function written in natural language to extract information from a PDF. The slide below shows an example of how we use natural language to extract the required fields in JSON format that would allow us to make this small pattern part of a larger app or data integration workflow.

Slide showing an example invoice on the left, the natural language used to extract the required fields, and the output in JSON. Also shown is an example of the SnapLogic Pipeline.Slide showing an example invoice on the left, the natural language used to extract the required fields, and the output in JSON. Also shown is an example of the SnapLogic Pipeline.

 

Prerequisites

In order to following along with this guide, you will need the items below to complete this guide: 

  • Access to GenAI App Builder (in your company’s organization or in SnapLabs)
  • Your own API account with access to Azure OpenAI, OpenAI, Amazon Bedrock Claude. 

⬆️ Import the pipeline

At the bottom of this post you will find several files if you want to just use a pattern to see this in action in your own environment and explore it further. If you are familiar with SnapLogic and want to build the Pipeline on your own you can do that as well and just download the example PDF or try your own! 

  • PurchaseOrderExample.pdf
  • InvoiceProcessing_CommunityArticlePipeline_2024_06_28.slp (zipped)

Once you are signed in to SnapLogic or SnapLabs you can start with the steps below to import the Pipeline:

  1. In Designer, click the icon shown in the screenshot below to import the Pipeline:
    RogerSramkoski_0-1719603019086.png
  2. Select the file in the File Browser window that pops up
  3. In the Add New Pipeline panel that opens you can change name and project location if desired
    RogerSramkoski_1-1719603019134.png
  4. Press the Save button in the lower-right corner

 

🚧 Parsing the file

 If you imported the pipeline using the steps above, then your pipeline should look like the one below. The steps below assume you imported the pipeline. If you are familiar enough with SnapLogic to build this on your own you can drag the Snaps shown below to create the Pipeline then follow along with us. 

RogerSramkoski_2-1719603019126.png

🔈 NOTE: The instructions here are completed with the Amazon Bedrock Prompt Generator and the Anthropic Claude on AWS for the last two Snaps in the Pipeline. You can swap these out for Azure OpenAI or OpenAI Snaps if you prefer to use those LLMs.

  1. Click the File Reader Snap to open its settings
  2. Click the icon at the far right of the File field as shown in the screenshot below
    RogerSramkoski_15-1719604137020.png
  3. Click the Upload File button in the upper-right corner of the window that pops up
    RogerSramkoski_16-1719604201700.png
  4. Select the PDF file from your file browser (download the file “” at the bottom of this post if you have not already)
  5. Save and close the File Reader Snap once your file is selected
  6. No edits are needed for the PDF Parser Snap, so we'll skip over that one
  7. Click the Mapper Snap
  8. Add $text in the Expression field and $context in the Target path fields as shown below
    RogerSramkoski_17-1719604420159.png
  9. Save and close the Mapper Snap
  10. Click on the fourth Snap, the Prompt Generator Snap (we will demonstrate here with the Amazon Bedrock Prompt Generator Snap - you do not have to use Amazon Bedrock though, you can any of the other LLM Prompt Generators we have like Azure OpenAI, OpenAI, etc.)
  11. Click the Edit Prompt button as shown in the screenshot below so we can modify the prompt used for the LLM
    RogerSramkoski_5-1719603019126.png
  12. You should see a pre-generated prompted like the one below:
    RogerSramkoski_6-1719603019131.png
  13. Copy the prompt below and replace the default prompt: 
    Instruction:
    Your task is to pull out the company name, the date created, 
    date shipped, invoice number, P.O. number, 
    vendor from vendor details, recipient name from recipient details, 
    subtotal, 'Shipping & handling', tax rate, sales tax, and 
    total from the context below.
    
    Give the results back in JSON.
    
    Context: {{context}}
  14. The Prompt Generator text should now look like the screenshot below:
    RogerSramkoski_7-1719603019130.png
  15. Click the Ok button in the lower-right corner to save our prompt changes
  16. Click on the last Snap, the Chat Completions Snap (we will demonstrate here with the Anthropic Claude on AWS Chat Completions Snap - you do not have to use Anthropic Claude on AWS though, you can any of the other LLM Chat Completions Snaps we have like Azure OpenAI, OpenAI, etc.)
  17. Click the Account tab
  18. Click Add Account; if you have an existing LLM account to use you can select that here and skip to step 22 below
  19. Select the type of account you want then press Continue - available options will depend on which LLM Chat Completions Snap you chose
  20. Enter in the required credentials for the LLM account you chose; here is an example of the Amazon Bedrock Account
    RogerSramkoski_8-1719603019121.png
  21. Press the Apply button when done entering the credentials
  22. Verify your account is now selected in the Account tab
  23. Click on the Settings 
  24. Click on the Suggest icon to the right of the Model name field as shown in the screenshot below and select the model you want to use
    RogerSramkoski_9-1719603019125.png
  25. Type $prompt in the Prompt field as shown in the screenshot below:
    RogerSramkoski_10-1719603019123.png
  26. Expand the Model Parameters section by clicking on it (if you are using OpenAI or Azure OpenAI, you can leave Maximum Tokens blank; for Anthropic Claude on AWS you will need to increase Maximum Tokens from 200 to something higher; you can see where we set 50,000 below)
    RogerSramkoski_11-1719603019123.png
  27. Save and close the Chat Completions Snap

 

🎬 Testing our example

At this point we are ready to test our Pipeline and observe the results! The screenshot below shows you where you can click to Validate the Pipeline, which should have every Snap turn green with preview output as shown below. If you have any errors or questions, please reply to share them with us!

RogerSramkoski_12-1719603019132.png

 

Here is the JSON output after the Anthropic Claude on AWS Chat Completions Snap (note that other LLMs will have different API output structures):

RogerSramkoski_13-1719603019133.png

 

Extras!

Want to play with this further? 

  • Try adding a Copy Snap after the Mapper and sending the file to multiple LLMs at once then review the results.
  • Try changing {{context}} in the Prompt Generator to something else so you can drop the Mapper from the pipeline


🏁 Wrapping up

Congratulations, you have now completed at least one GenAI App Builder integration in SnapLogic! 😎 Stay tuned to the SnapLabs channel here in the Integration Nation for more content on GenAI App Builder in the future! Please share any thoughts, comments, concerns, or feedback in a reply or DM @RogerSramkoski!


0 REPLIES 0