Skip to content

Latest commit

 

History

History
69 lines (41 loc) · 5.06 KB

File metadata and controls

69 lines (41 loc) · 5.06 KB

Exercise 08 - Define the Job Posting Service

Imagine you are an AI Engineer and you have been tasked with developing a solution to enable Hiring Managers to create job postings with ease. You are going to utilize Artificial Intelligence and the SAP Cloud Application Programming Model to create an application to create these job postings using a chat model provided through SAP AI Core. These job postings will then be stored in the SAP HANA Cloud database instance on SAP Business Technology Platform.

In this exercise, you will learn:

  • How to define a CAP OData service using Core Data Service (CDS).
  • How to expose entities from your OData service schema definition.

Create the job posting service CDS definition

The job posting service is responsible for the creation and deletion of job postings. The creation of a job posting sends a user query to a chat model via SAP AI Core and the SAP Cloud SDK for AI. You will utilize the orchestration package of the SDK to easily create a message for the chat model and send it via an orchestration client. The response from the chat model will then be stored in the SAP HANA Cloud database. You will implement two ways to delete job postings, one which you can explicitly specify what posting should be deleted and one that let you drop the whole table.

👉 Open the job-posting-service.cds file.

👉 Below the JobPostings projection add the createJobPosting function:

function createJobPosting(user_query : String) returns String;

This function takes a user_query parameter, which represents the user's input to the chat model. The function returns a String that is simply a error or success message.

This function will execute a RAG flow to create a Job Posting. With the SAP Cloud SDK for AI, you get different levels of abstraction on how you want to use SAP's AI capabilities.

You can use the orchestration service, which you will do in exercise 10, to have a given workflow on how to work with a chat and embedding model. It allows you to define aspects of a complete interaction flow with the different models in a more managed (orchestrated) way.

If you have the need to go one level down and access different features Langchain is providing, you can use the langchain package by the SAP Cloud SDK for AI. This package is basically wrapping the Langchain APIs and adds additional features to it, helping you to more easily connect and interact with SAP's AI solutions. This is really handy as you don't have to implement the interface towards SAP yourself but still have the capabilities of Langchain right at your fingertips.

In this CodeJam, you are using the orchestration client to make the RAG flow as easy as possible.

Now, let's add additional functions to make it possible to delete job postings.

👉 Right below the last function definition, add the deleteJobPosting and deleteJobPostings functions:

function deleteJobPosting(id : String) returns String;
function deleteJobPostings() returns String;

Summary

At this point, you have learned what SAP AI Core and SAP AI Launchpad is, how to define and deploy database artifacts to SAP HANA Cloud, and how to define an OData service using CDS.

In the next exercise, you will implement the business logic, the function handlers, for the job posting service.

Questions for Discussion

  1. What is the purpose of the createJobPosting function in the CDS definition?
Answer The `createJobPosting` function is responsible for creating a job posting by taking a `user_query` (which is the user input to the chat model) as its parameter. It interacts with SAP generative AI Hub to process the query and let the proxy chat model generate a job posting. The creation process involves a Retrieval-Augmented Generation (RAG) flow, which helps in generating the job posting content based on contextual information provided by you.
  1. What are the benefits of using the orchestration service or Langchain package in this exercise?
Answer The orchestration service simplifies the interaction with SAP’s AI models by providing a high-level workflow for handling chat and embedding models. It allows you to define the interaction flow in a more managed way. Alternatively, the Langchain package gives more control and flexibility by wrapping Langchain APIs and adding features that help easily connect and interact with SAP AI solutions. It allows you to dive deeper into the AI functionality while still benefiting from the integration features offered by the SAP Cloud SDK for AI.

Further reading


Next exercise