Skip to content

Commit 5ee8447

Browse files
authored
access config part of tutorial
1 parent 948eeaf commit 5ee8447

1 file changed

Lines changed: 113 additions & 4 deletions

File tree

tutorials/ai-core-orchestration-consumption/ai-core-orchestration-consumption.md

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ author_profile: https://github.com/I321506
6666

6767
• SAP Cloud SDK for AI: Uses the `dotenv` library to load environment variables. If you encounter issues with the dotenv library, ensure it is installed correctly by running:
6868

69-
```CODE
70-
npm install dotenv
71-
```
69+
```CODE
70+
npm install dotenv
71+
```
7272

7373
```CODE
7474
import dotenv from 'dotenv';
@@ -81,6 +81,115 @@ console.log(process.env.AICORE_SERVICE_KEY);
8181

8282
**Next.js:** Requires specific configuration for loading environment variables.
8383

84+
[OPTION END]
85+
86+
[OPTION BEGIN [SAP Cloud SDK for Java]]
87+
88+
[Create a service key](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-service-key) for your AI Core instance and copy the JSON object.
89+
90+
• Create a `.env`file in the **working directory** from which you run the code. Add the following line using the copied JSON:
91+
92+
```txt
93+
AICORE_SERVICE_KEY={"clientid": "...", "clientsecret": "...", "url": "...", "serviceurls": { "AI_API_URL": "..." } }
94+
```
95+
> [!IMPORTANT]
96+
The value of `AICORE_SERVICE_KEY` must be a single line, so remove any line breaks from the service key JSON.
97+
98+
• For other options of access configuration and detailed information on installation and usage of the **SAP Cloud SDK for AI (for Java)**, visit the official
99+
[GitHub repository](https://github.com/SAP/ai-sdk-java). This page provides comprehensive steps to set up and integrate the SDK effectively in your projects.
100+
101+
[OPTION END]
102+
103+
[OPTION BEGIN [Bruno]]
104+
#### Download and Import the Bruno Collection
105+
- Download the [bruno_collections](img/Bruno_Collection.json) file
106+
107+
- Navigate to the Bruno Collections section
108+
109+
- Upload the .json file to import the collection. Follow the screenshot attached for reference
110+
![img](img/img001.png)
111+
![img](img/img003.png)
112+
![img](img/img005.png)
113+
#### Set Environment Variables
114+
- From the imported collection, select the get_token query.
115+
116+
- Click on "No Environment" and then select "Configure".
117+
118+
![img](img/no_env.png)
119+
- Populate the following environment variables with values from the service key:
120+
- ai_auth_url → url from the service key.
121+
- ai_api_url → serviceurls.AI_API_URL from the service key.
122+
- client_id → clientid from the service key.
123+
- client_secret → clientsecret from the service key.
124+
- resource_group → Specify a resource group name.
125+
126+
![img](img/img009.png)
127+
- Save the environment configuration.
128+
129+
- Click on "No Environment" in the top-right corner and select "Grounding-test".
130+
![img](img/env_set.png)
131+
#### Generate the Token
132+
- Select the get_token request from the root folder of the imported collection.
133+
134+
- Execute the request to generate the token.
135+
![img](img/get_token.png)
136+
137+
**NOTE**: If the token expires at any point during execution, repeat this step to regenerate it.
138+
139+
[OPTION END]
140+
141+
142+
### Create Configuration for Orchestration deployment
143+
144+
[OPTION BEGIN [AI Launchpad]]
145+
146+
Go to the Configuration section within your chosen Resource Group.
147+
148+
![img](img/image008.png)
149+
150+
• Fill in Deployment Details, Under configuration, input the following details:
151+
152+
Name: "orchestration"
153+
154+
Executable: "orchestration"
155+
156+
Scenario: "orchestration"
157+
158+
Version: "0.0.1"
159+
160+
• Click Next after entering each detail.
161+
162+
![img](img/image009.png)
163+
164+
[OPTION END]
165+
166+
[OPTION BEGIN [Gen AI SDK]]
167+
168+
• Create a folder named orchestration, then navigate to this folder using VS Code.
169+
170+
• Inside the folder, create a new file with any name but ensure it has the .ipynb extension.
171+
172+
![img](img/image010.png)
173+
174+
You'll create a configuration that defines the orchestration setup. Use the following code to initialize your configuration.
175+
176+
```CODE
177+
178+
# Define scenario ID, executable ID, and configuration suffix
179+
scenario_id = "orchestration"
180+
executable_id = "orchestration"
181+
config_suffix = "config-new"   # Enter your configuration name
182+
config_name = f"{config_suffix}-orchestration"
183+
184+
# Create a new configuration
185+
config = ai_core_client.configuration.create(
186+
    scenario_id=scenario_id,
187+
    executable_id=executable_id,
188+
    name=config_name
189+
)
190+
print(f"Configuration created successfully with ID: {config.id} and Name: {config_name}")
191+
192+
84193
[OPTION END]
85194
86195
[OPTION BEGIN [Bruno]]
@@ -923,4 +1032,4 @@ Data masking and content filtering are available to enhance data privacy and saf
9231032

9241033
Data masking and content filtering are available to enhance data privacy and safety. Data masking hides sensitive information like phone numbers or organization names, while content filtering can screen for categories such as hate self-harm, sexual content, and violence. In this tutorial, the response generated by the LLM models may carry sensitive information, such as names and phone numbers etc.. For further enhancement, refer to the next tutorial on implementing these modules.
9251034

926-
[OPTION END]
1035+
[OPTION END]

0 commit comments

Comments
 (0)