pawit_roy
Employee
Employee

GenAI is a powerful toolset designed to help you develop and optimize large language models (LLMs) such as OpenAI, Claude, Google Gemini, and more, within your own data pipelines on the SnapLogic platform. By leveraging SnapLogic Designer, you can seamlessly integrate LLMs with your data pipeline and store the responses on various data platforms supported by SnapLogic.

Get Started

This section will guide you through initiating your first interaction with LLM models on the SnapLogic platform. Follow these steps to get familiar with GenAI.

1. Open the Designer page on SnapLogic and create a new, empty pipeline.

pawit_roy_0-1728051016737.png

2. Introduce the new Snap called “Chat Completion.” This Snap allows you to send prompts to LLM models. Locate it in the Snap list by searching for “Chat Completion.”

pawit_roy_1-1728051016799.png

3. Drag the Chat Completion Snap to the canvas screen (we’ll use OpenAI as an example).

pawit_roy_2-1728051016720.png

4. Configuring the Chat Completion Snap

a. Click on the Snap to open the configuration modal.

b. In the “Account” tab, select the account that will be used to connect to the LLM model.

i. (Optional) If necessary, you can create a new account by selecting “Add New Account,” choosing the location, and entering your credentials. You can retrieve your API key from OpenAI API Keys.

pawit_roy_3-1728051016528.png

pawit_roy_4-1728051016560.png

pawit_roy_22-1728051516904.png

5. Move to the “Settings” tab.

pawit_roy_5-1728051016721.png

a. Select a model from the list of available options by clicking pawit_roy_6-1728051016492.png to list the available models.pawit_roy_7-1728051016719.png

 

b. Customize the “prompt” field, e.g., by entering “Hello GenAI.”

pawit_roy_8-1728051016740.png

6. Save and close the settings. The pipeline should validate automatically, but if it doesn’t, you can manually validate it by clicking the validate button pawit_roy_9-1728051016709.png.

pawit_roy_10-1728051016722.png

7. To check the result, click the circle to the right of the Snap. The LLM model’s response will appear in the “content” field. For example, it might return “Hello! How can I assist you today?” The “finish_reason” field will indicate “stop,” meaning the full chat completion has been generated.

pawit_roy_11-1728051016738.png

Using Prompt Generator

In real-world scenarios, prompts are often more complex than a single sentence. To handle this, we introduced the “Prompt Generator” Snap, which helps create prompts using preset templates such as context Q&A. Let’s explore how to use this feature.

1. Search for “Prompt Generator” in the side panel and drag it to the canvas screen. In this example, we will use the OpenAI Prompt Generator.

pawit_roy_12-1728051016730.png

2. To simulate mock input, drag the “JSON Generator” Snap to the canvas screen.

pawit_roy_13-1728051016516.png

3. Connect the two Snaps as shown below:

pawit_roy_14-1728051016486.png4. Configure the JSON Generator to output the following data:

[
 {
   "occupation": "astronaut",
   "situation": "On a distant planet, exploring uncharted terrain."
 }
]

The setting should be like the below:

pawit_roy_15-1728051016522.png

5. Save and close the configuration.

6. Next, configure the Prompt Generator:

pawit_roy_16-1728051016590.png

a. Click on Edit prompt and remove any existing text.

b. Paste the following text into the prompt box: “You are a {{occupation}}. {{situation}}. What action do you take?”

pawit_roy_17-1728051016492.png

7. Save and close the configuration.

8. To test the prompt, validate the pipeline by clicking the validate button pawit_roy_18-1728051016710.png. The result will appear in the prompt field, showing how the template text is replaced with values from the input.

pawit_roy_19-1728051016750.png

 

Example

  • Input:
{
  "occupation": "astronaut",
  "situation": "On a distant planet, exploring uncharted terrain."
}
  • Template:

“You are a {{occupation}}. {{situation}}. What action do you take?”

  • Output:

“You are a astronaut. On a distant planet, exploring uncharted terrain.. What action do you take?”

Example Use Cases

Below are some examples of how to use prompts to accomplish real tasks. You can modify these templates to suit your needs.

Text Summarization

Prompt:

Explain AI

A:

Output:

Artificial Intelligence (AI) refers to the simulation of human intelligence processes by computer systems. These processes include learning (the acquisition of information and rules for using it), reasoning (using rules to reach approximate or definite conclusions), and self-correction. AI can be classified into several categories:

  1. **Narrow AI**: Also known as weak AI, this type of AI is designed for specific tasks. Examples include virtual assistants like Siri and Alexa, recommendation systems, and image recognition software. Narrow AI does not possess general intelligence—it operates within a limited context.
  2. **General AI**: Also known as strong AI or AGI (Artificial General Intelligence), this type refers to a hypothetical AI that can understand, learn, and apply knowledge across a wide range of tasks, much like a human. As of now, AGI remains a theoretical concept and has not been achieved.
  3. **Machine Learning (ML)**: A subset of AI that involves the development of algorithms that enable computers to learn from and make predictions or decisions based on data. ML can be further divided into supervised learning, unsupervised learning, and reinforcement learning.
  4. **Deep Learning**: A specialized form of machine learning that uses neural networks with many layers (hence "deep"), allowing the system to learn from vast amounts of data. It is particularly effective in areas like image and speech recognition.
  5. **Natural Language Processing (NLP)**: This area of AI focuses on the interaction between computers and humans through natural language. It enables machines to understand, interpret, and respond to human language in a way that is both meaningful and useful.

AI has numerous applications across various industries, including healthcare (diagnosing diseases), finance (fraud detection), transportation (self-driving cars), and entertainment (recommendation systems). While the potential benefits of AI are vast, there are also concerns related to ethics, privacy, job displacement, and the need for regulation to ensure its responsible use.

To summarize the explanation into one sentence:

Prompt:

Artificial Intelligence (AI) refers to the simulation of human intelligence processes by computer systems. These processes include learning (the acquisition of information and rules for using it), reasoning (using rules to reach approximate or definite conclusions), and self-correction. AI can be classified into several categories:

  1. **Narrow AI**: Also known as weak AI, this type of AI is designed for specific tasks. Examples include virtual assistants like Siri and Alexa, recommendation systems, and image recognition software. Narrow AI does not possess general intelligence—it operates within a limited context.
  2. **General AI**: Also known as strong AI or AGI (Artificial General Intelligence), this type refers to a hypothetical AI that can understand, learn, and apply knowledge across a wide range of tasks, much like a human. As of now, AGI remains a theoretical concept and has not been achieved.
  3. **Machine Learning (ML)**: A subset of AI that involves the development of algorithms that enable computers to learn from and make predictions or decisions based on data. ML can be further divided into supervised learning, unsupervised learning, and reinforcement learning.
  4. **Deep Learning**: A specialized form of machine learning that uses neural networks with many layers (hence "deep"), allowing the system to learn from vast amounts of data. It is particularly effective in areas like image and speech recognition.
  5. **Natural Language Processing (NLP)**: This area of AI focuses on the interaction between computers and humans through natural language. It enables machines to understand, interpret, and respond to human language in a way that is both meaningful and useful.

AI has numerous applications across various industries, including healthcare (diagnosing diseases), finance (fraud detection), transportation (self-driving cars), and entertainment (recommendation systems). While the potential benefits of AI are vast, there are also concerns related to ethics, privacy, job displacement, and the need for regulation to ensure its responsible use.

Explain the above in one sentence:

Output:

Artificial Intelligence (AI) encompasses the simulation of human cognitive processes by computer systems, classified into categories such as Narrow AI for specific tasks, General AI for broad understanding, Machine Learning (ML) for data-driven learning, Deep Learning for processing large datasets with neural networks, and Natural Language Processing (NLP) for human-computer language interaction, with applications across various industries alongside ethical and regulatory concerns.

Information Extraction

Prompt:

Author-contribution statements and acknowledgements in research papers should state clearly and specifically whether, and to what extent, the authors used AI technologies such as ChatGPT in the preparation of their manuscript and analysis. They should also indicate which LLMs were used. This will alert editors and reviewers to scrutinize manuscripts more carefully for potential biases, inaccuracies and improper source crediting. Likewise, scientific journals should be transparent about their use of LLMs, for example when selecting submitted manuscripts.

Mention the large language model based product mentioned in the paragraph above:

Output:

The large language model based product mentioned in the paragraph above is ChatGPT.

Question Answering

Prompt:

Answer the question based on the context below. Keep the answer short and concise. Respond "Unsure about answer" if not sure about the answer.

Context: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.

Question: What was OKT3 originally sourced from?

Answer:

Output:

Mice.

Text Classification

Prompt:

Classify the text into neutral, negative or positive. 

Text: I think the food was okay. 

Sentiment:

Output:

Neutral

Conversation

Prompt:

The following is a conversation with an AI research assistant. The assistant tone is technical and scientific.

Human: Hello, who are you?

AI: Greeting! I am an AI research assistant. How can I help you today?

Human: Can you tell me about the creation of blackholes?

AI:

Output:

Sure! Black holes are regions of spacetime where the gravitational force is so strong that nothing, not even light, can escape from it. They are created when a very massive star dies and its core collapses in on itself, forming a singularity of infinite density. The intense gravity of the singularity pulls in all the matter and radiation around it, creating the black hole.

Code Generation

Prompt:

"""

Table departments, columns = [DepartmentId, DepartmentName]

Table students, columns = [DepartmentId, StudentId, StudentName]

Create a MySQL query for all students in the Computer Science Department

"""

Output:

SELECT StudentId, StudentName 

FROM students 

WHERE DepartmentId IN (SELECT DepartmentId FROM departments WHERE DepartmentName = 'Computer Science');

Reasoning

Prompt:

The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. 

Solve by breaking the problem into steps. First, identify the odd numbers, add them, and indicate whether the result is odd or even. 

Output:

Odd numbers: 15, 5, 13, 7, 1

Sum: 41 

41 is an odd number.