Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Subject: Bestellung #1234567890 Verspätet - John Johnson Nachricht: Halle, ich schreibe ihnen um mich nach dem Status meiner Bestellung mit der Bestellnr. +1234567890 zu erkundigen. Die Lieferung war eigentlich für gestern geplant, ist bisher jedoch nicht erfolgt. Mein Name ist John Johnson und meine Lieferadresse lautet 125 Cole Meadows Drive Palo Alto, California 94301. Bitte lassen Sie mich per Telefon unter der Nummer +1 505802 2172 wissen, wann ich mit meiner Lieferung rechnen kann. Danke!"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Subject: Bestellung #1234567890 Verspätet - John Johnson Nachricht: Halle, ich schreibe ihnen um mich nach dem Status meiner Bestellung mit der Bestellnr. +1234567890 zu erkundigen. Die Lieferung war eigentlich für gestern geplant, ist bisher jedoch nicht erfolgt. Mein Name ist John Johnson und meine Lieferadresse lautet 125 Cole Meadows Drive Palo Alto, California 94301. Bitte lassen Sie mich per Telefon unter der Nummer +1 505802 2172 wissen, wann ich mit meiner Lieferung rechnen kann. Danke!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load environment variables\n",
"\n",
"In this step, we use the dotenv package to load environment variables from a .env file. This approach helps manage sensitive configuration details like API keys and service credentials without hardcoding them in the code.\n",
"\n",
"Key Points:\n",
"\n",
"dotenv: Automatically loads environment variables defined in a .env file into process.env.\n",
"\n",
"Access Environment Variables: The process.env object is used to access these variables in the application."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import dotenv from 'dotenv';\n",
"dotenv.config();\n",
" \n",
"console.log(process.env.AICORE_SERVICE_KEY); "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a New Orchestration Configuration\n",
"In this step, we define a function to create an orchestration configuration using the ConfigurationApi from the SAP AI SDK. This configuration integrates various parameters needed for orchestration, such as the executable ID and scenario ID.\n",
"\n",
"Key Points:\n",
"\n",
"ConfigurationApi: Provides methods for interacting with the SAP AI SDK's configuration services.\n",
"\n",
"parameterBindings: Specifies the parameters used for orchestration."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Configuration created\n"
]
}
],
"source": [
"import { ConfigurationApi } from '@sap-ai-sdk/ai-api';\n",
"\n",
"const RESOURCE_GROUP = 'grounding'; // Please change to your desired resource group\n",
"\n",
"// Create orchestration configuration using ConfigurationApi\n",
"async function createOrchestrationConfiguration() {\n",
" try {\n",
" const response = await ConfigurationApi\n",
" .configurationCreate({\n",
" name: 'orchestration-config', // Choose a meaningful name\n",
" executableId: 'orchestration', // Orchestration executable ID\n",
" scenarioId: 'orchestration', // Orchestration scenario ID\n",
" }, {'AI-Resource-Group': RESOURCE_GROUP}).execute();\n",
"\n",
" return response;\n",
" } catch (error: any) {\n",
" // Handle API errors\n",
" console.error('Configuration creation failed:', error.stack);\n",
" }\n",
"}\n",
"\n",
"const configuration = await createOrchestrationConfiguration();\n",
"console.log(configuration?.message); // Print the configuration response message"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deployment of orchestration\n",
"This step involves creating a deployment using the specified configuration and resource group. The deployment is handled via the DeploymentApi, which streamlines the process of activating the orchestration setup.\n",
"\n",
"Key Points:\n",
"\n",
"DeploymentApi: Used for initiating the deployment based on the given configuration.\n",
"\n",
"createDeployment Function: This function handles the API call to create the deployment."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Deployment scheduled.\n"
]
}
],
"source": [
"import { DeploymentApi } from '@sap-ai-sdk/ai-api'; \n",
"\n",
"// Create Orchestration deployment using DeploymentApi\n",
"async function createOrchestrationDeployment() { \n",
" // Extract the configuration ID from the result of the previous step \n",
" const configurationId = configuration.id;\n",
"\n",
" try { \n",
" const response = await DeploymentApi\n",
" .deploymentCreate(\n",
" { configurationId }, \n",
" { 'AI-Resource-Group': RESOURCE_GROUP }\n",
" ).execute(); \n",
"\n",
" return response;\n",
" } catch (error: any) { \n",
" console.error('Deployment creation failed:', error.stack);\n",
" } \n",
"} \n",
" \n",
"const deployment = await createOrchestrationDeployment();\n",
"console.log(deployment?.message) // Print the deployment creation response"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Basic Orchestration Pipeline"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"const cvContent = await Deno.readTextFile('./cv.txt');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Templating\n",
"\n",
"Explanation of Templating Code\n",
"\n",
"This code defines a template for an AI assistant using orchestration configuration. The `Template` object is set up with system and user messages to guide the assistant’s response behavior. \n",
"\n",
"Key Components:\n",
"- **SystemMessage**: Sets a predefined instruction for the AI assistant. This message typically includes the assistant's role and any specific guidelines it should follow.\n",
"- **UserMessage**: Represents the user's input and how it is structured in the conversation.\n",
" \n",
"In this revised prompt, only queries are passed to the assistant without any additional context. The AI is expected to respond based solely on the provided input.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Define the LLM \n",
"\n",
"The LLM class is used to configure and initialize a model for generating text based on specific parameters. In this example, we'll use the model to perform the content creation task.\n",
"\n",
"ℹ️Note that virtual deployment of the model is managed automatically by the Orchestration Service, so no additional deployment setup is required on your part."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Generate Responses \n",
"\n",
"This step outlines the process of generating responses for a set of queries using a defined model. The generateResponses function executes queries to gather AI-generated responses.\n",
"\n",
"Key Points:\n",
"\n",
"Query Execution: Uses OrchestrationClient to generate responses for each query."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"John Doe is a skilled data scientist with over three years of experience in data analysis, statistical modeling, and machine learning, aiming to utilize his proficiency in predictive modeling and data visualization to inform decision-making at prospective employers. He holds a Master's degree in Data Science from the University of California, Berkeley, and a Bachelor's degree in Computer Science from UCLA. John is proficient in several programming languages including Python, R, SQL, and Java, and is experienced with data analysis and visualization tools such as Pandas, NumPy, Matplotlib, Seaborn, and Tableau, alongside machine learning libraries like Scikit-learn, TensorFlow, and Keras. His professional experience includes working as a Data Scientist at DataCorp Inc., where he developed predictive models that increased ROI by 20% and visualized KPIs using Tableau to improve stakeholder decision-making. Previously, as a Data Analyst Intern at Analytics Solutions, he contributed to business growth by analyzing large datasets and assisting in the development of automated reporting tools. Among his notable projects, John conducted customer segmentation analysis using K-means clustering and achieved 85% accuracy in predictive stock price modeling through time series analysis. He holds certifications as a Certified Data Scientist by the Data Science Council of America and a Machine Learning Specialization from Coursera. John is affiliated with professional bodies such as the Association for Computing Machinery and the Data Science Society. Outside work, he enjoys exploring new technologies, reading on AI and machine learning, traveling, and playing competitive video games, though he has expressed dislike for the Azure Cloud platform and prefers to avoid routine tasks. Contact information includes 1234 Data St, San Francisco, CA 94101, phone number (123) 456-7890, and email johndoe@email.com.\n"
]
}
],
"source": [
"import { OrchestrationClient } from '@sap-ai-sdk/orchestration';\n",
"\n",
"const orchestrationClient = new OrchestrationClient({\n",
" promptTemplating: {\n",
" model: {\n",
" name: 'gpt-4o'\n",
" },\n",
" prompt: {\n",
" template: [\n",
" {\n",
" role: 'system',\n",
" content:\n",
" 'You are a helpful AI assistant for HR. Summarize the following CV in 10 sentences, focusing on key qualifications, work experience, and achievements. Include personal contact information, organizational history, and personal interests.'\n",
" },\n",
" {\n",
" role: 'user',\n",
" content: 'Candidate Resume:\\n{{ ?candidate_resume }}'\n",
" }\n",
" ]\n",
" }\n",
" }\n",
"});\n",
"\n",
"const response = await orchestrationClient.chatCompletion({\n",
" placeholderValues: {\n",
" candidate_resume: cvContent\n",
" }\n",
"});\n",
"console.log(response.getContent());"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Deno",
"language": "typescript",
"name": "deno"
},
"language_info": {
"codemirror_mode": "typescript",
"file_extension": ".ts",
"mimetype": "text/x.typescript",
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading