Developing Basic Prompts for Common Queries

Objectives

After completing this lesson, you will be able to:
  • Identify business scenario for the learning journey
  • Develop basic prompts using generative AI hub in SAP AI launchpad

Identify the Facility Management Scenario

Facility Solutions Company is a premier provider of comprehensive facility management, maintenance, and cleaning services tailored for both residential and commercial properties. Their mission is to ensure that your environment remains safe, efficient, and impeccably maintained, allowing you to focus on your core activities without the hassle of facility upkeep.

Their target markets are luxury residential complexes, apartments, and individual homes. They also serve commercial Properties like office buildings, retail spaces, industrial facilities, and educational institutions.

Business Problem:

Facility solutions company receives thousands of mails pertaining to customers’ requests, complaints, and other messages. The company maintains internal applications to address customer requests and complaints and prioritize them to address these requests in a timely and correct manner.

However, categorizing these mails include manual process to transfer data from mails to internal applications, categorizing, and then prioritizing these tasks.

They turn towards generative AI hub to address this problem.

We will provide stepwise solutions to this problem in this learning journey.

Get Started with Generative AI hub in SAP AI Launchpad

The solution entails assigning incoming mails to the correct service category and assign them correct priorities like urgency and sentiment.

Let’s get started with developing prompt.

First task is to get started with Generative AI hub in SAP AI Launchpad and then categorize messages according to the incoming mail.

Develop a Prompt in AI Launchpad

We will now find the urgency and sentiment in an incoming mail .

Developing a prompt to solve a business problem is a stepwise ideation process. This process is explained in the following steps:

1. Develop a basic prompt

We'll start with a basic prompt and then develop the prompt, finding an output that can be used by application within the company.

The first prompt is:

Python
123456789101112131415161718192021222324
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Your task is to extract - urgency - sentiment "

We start with using an open-source model like meta--llama3-70b-instruct.

Open-source LLMs provide several advantages. They reduce costs, offer transparency, and allow for customization. Additionally, they come with community support, ensure data security, and prevent vendor lock-in. These factors make open-source LLMs a smart and practical choice for developing and deploying language models.

It’s a good practice to think about cost and performance optimization before starting to deep dive into using LLMs.

However, as we can see this response is too lengthy. Our objective is to assign urgency and sentiment to the mails that can be used as an input for a software. This lengthy response is not useful for us as of now. Let us continue to develop it.

Note

You may get a slightly different response to the one shown here and in all the remaining responses of models shown in this learning journey.

When you execute the same prompt in your machine, an LLM produces varying outputs due to its probabilistic nature, temperature setting, and non-deterministic architecture, leading to different responses even with slight setting changes or internal state shifts.

2. Assign values to urgency and sentiment

We will now assign some basic urgency and sentiment values and execute the prompt.

Python
1234567891011121314151617181920212223
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Your task is to extract: - "urgency" as one of `low`, `medium`, `high` - "sentiment" as one of `positive`, `neutral`, `negative`

See the following video to execute the prompt.

3. Generate JSON output

We need the output of these values in a format that can be used as an input for a software. We decide to use the JSON output.

JSON offers a simple, language-independent, and lightweight solution for efficient data exchange. It can handle complex structures while remaining easy to parse and generate. JSON's widespread use in APIs and web services ensures interoperability, reduces bandwidth and storage requirements, and simplifies the development process.

We use the following prompt:

Python
123456789101112131415161718192021222324
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Extract and return a json with the following keys and values: - "urgency" as one of `low`, `medium`, `high` - "sentiment" as one of `positive`, `neutral`, `negative` Your complete message should be a valid json string that can be read directly and only contain the keys mentioned in the list above.

The prompt is the same as the previous prompt, but the last few sentences now requests a JSON string.

We again execute this prompt in SAP AI Launchpad.

The following screenshot shows the version 3 of the prompt:

A Prompt Editor interface from a Generative AI application. The editor is titled Analyzing mail categories and is on version 3. The prompt message instructs to extract and return a JSON with keys urgency and sentiment with specified values. The response box contains the JSON output: {urgency: high, sentiment: neutral}. The model used is meta-llama3-70b-instruct. The metadata section includes tags and notes, with an Update button. The interface also has options to save, create new, and select prompts.

You can see a JSON output.

4. Ensure that the JSON formatting is correct

This step is needed when the JSON output format is not clear in the previous prompt. You can make it clearer using the following prompt:

Python
123456789101112131415161718192021222324
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Extract and return a json with the follwoing keys and values: - "urgency" as one of `low`, `medium`, `high` - "sentiment" as one of `positive`, `neutral`, `negative` Your complete message should be a valid json string that can be read directly and only contain the keys mentioned in the list above. Never enclose it in ```json...```, no newlines, no unnecessary whitespaces.

This prompt gives clear instruction to provide a clean format without any quotes or whitespaces.

The following screenshot shows version 4 of the prompt:

A Prompt Editor interface from a Generative AI tool. The interface includes sections for the prompt, response, and metadata. The prompt instructs the AI to extract and return a JSON object with keys urgency and sentiment based on specified values. The response box contains the JSON output: {urgency:high,sentiment:neutral}. The model used is meta-llama3-70b-instruct. There are also options to save, create new, and select prompts, as well as a section for metadata tags and notes.

You can see that the JSON output is now clear. This is ready for software consumption.

5. Simple Categories Based on Business Functions

We have associated urgency and sentiment to a mail. However, we also need more tags for each message to categorize them for business needs. We can start with a simple prompt:

Python
123456789101112131415161718192021
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Assign a list of matching support category to the message.

The following screenshot shows the output of this prompt:

A Prompt Editor interface from a Generative AI tool. The editor is titled Analyzing mail categories and is at version 5. The interface is divided into three main sections: Prompt, Response, and Metadata.

You can see categories are assigned to the message.

6. Assigning values to categories from a list

As you can see, the categories have multiple values, at times overlapping with earlier values like urgency. Let’s align them to values defined in the company. Aligning the output to business needs is a key step in addressing a business problem.

Python
12345678910111213141516171819202122
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Assign a list best matching support category tags to the message: `facility_management_issues`, `cleaning_services_scheduling`, `general_inquiries`, `specialized_cleaning_services`, `routine_maintenance_requests`, `emergency_repair_services`, `sustainability_and_environmental_practices`, `training_and_support_requests`, `quality_and_safety_concerns`, `customer_feedback_and_complaints`

The following screenshot shows the output of this prompt in SAP AI Launchpad.

A Prompt Editor interface from a Generative AI application. The interface includes sections for the prompt, response, and metadata. The Prompt section contains a message instructing the AI to assign support category tags to a message. The Metadata section shows fields for tags and notes, both of which are currently empty. There are buttons for saving, creating new prompts, and selecting options at the top of the interface.

You can see that categories are assigned to values from the list. These are streamlined for business processing.

7. Generate JSON output for categories values

Similar to step 3 earlier, we need the JSON output for processing these values in a software. We also ensure that the format of the JSON output is without any unnecessary symbols or space.

We use the following prompt:

Python
1234567891011121314151617181920212223
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Extract and return a json with the follwoing keys and values: - "categories" list of the best matching support category tags from: `facility_management_issues`, `cleaning_services_scheduling`, `general_inquiries`, `specialized_cleaning_services`, `routine_maintenance_requests`, `emergency_repair_services`, `sustainability_and_environmental_practices`, `training_and_support_requests`, `quality_and_safety_concerns`, `customer_feedback_and_complaints` Your complete message should be a valid json string that can be read directly and only contain the keys mentioned in the list above. Never enclose it in ```json...```, no newlines, no unnecessary whitespaces.

The following screenshot shows the output of this prompt in SAP AI Launchpad.

A Prompt Editor interface from a Generative AI tool. The editor is used to analyze mail categories. The interface includes sections for the prompt, response, and metadata. The prompt section contains a message with instructions for generating a valid JSON string containing specific keys. The response section displays a JSON string with categories: routine_maintenance_requests, emergency_repair_services, and facility_management_issues. The model used is meta-llama3-70b-instruct. There are options to save, create new, and select prompts.

You can see categories in the JSON output that can be processed in a software.

8. Combining All the Steps

We have taken a step-by-step approach to arrive at proper values of urgency, sentiment, and categories in JSON format. Now, let us combine all these steps into a single prompt:

Python
12345678910111213141516171819202122232425
Giving the following message: --- Subject: Urgent HVAC System Repair Needed Dear Support Team, I hope this message finds you well. My name is [Sender], and I am reaching out to you from [Residential Complex Name], where I have been residing for the past few years. I have always appreciated the meticulous care and attention your team provides in maintaining our facilities. However, I am currently facing a pressing issue with the HVAC system in my apartment. Over the past few days, the system has been malfunctioning, resulting in inconsistent temperatures and, at times, complete shutdowns. Given the current weather conditions, this has become quite unbearable and is affecting my daily routine significantly. I have attempted to troubleshoot the problem by resetting the system and checking the thermostat settings, but these efforts have not yielded any improvement. The situation seems to be beyond my control and requires professional intervention. I kindly request that a repair team be dispatched immediately to address this urgent issue. The urgency of the matter cannot be overstated, as it is impacting not only my comfort but also my ability to carry out daily activities effectively. Thank you for your prompt attention to this matter. I look forward to your swift response and resolution. Best regards, [Sender] --- Extract and return a json with the following keys and values: - "urgency" as one of `low`, `medium`, `high` - "sentiment" as one of `positive`, `neutral`, `negative` - "categories" list of the best matching support category tags from: `facility_management_issues`, `cleaning_services_scheduling`, `general_inquiries`, `specialized_cleaning_services`, `routine_maintenance_requests`, `emergency_repair_services`, `sustainability_and_environmental_practices`, `training_and_support_requests`, `quality_and_safety_concerns`, `customer_feedback_and_complaints` Your complete message should be a valid json string that can be read directly and only contain the keys mentioned in the list above. Never enclose it in ```json...```, no newlines, no unnecessary whitespaces.

The following screenshot shows the output of this prompt in SAP AI Launchpad.

A Prompt Editor interface from a Generative AI tool. The interface includes sections for the prompt, response, and metadata. The prompt section contains a message instructing the AI to categorize mail into specific categories and to return the response in JSON format. The response section displays the AI's output in JSON format, indicating high urgency, neutral sentiment, and categories including facility_management_issues, emergency_repair_services, and routine_maintenance_requests. The model used is meta-llama3-70b-instruct. There are options to save, create new, and select prompts at the top right.

You can see the consolidated output that assigns urgency, sentiment, and categories to customer messages that can be used in software.

You have successfully developed a prompt to move towards a solution of the problem.

In the next unit, we'll learn to use generative-ai-hub-sdk for the same prompts and then evaluate the response from this prompt.

Log in to track your progress & complete quizzes