@sap-ai-sdk/orchestration 1.4.1-20241220013116.0 → 1.4.1-20241221013105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,7 @@ This package incorporates generative AI orchestration capabilities into your AI
15
15
  - [Content Filtering](#content-filtering)
16
16
  - [Data Masking](#data-masking)
17
17
  - [Grounding](#grounding)
18
+ - [Using a JSON Configuration from AI Launchpad](#using-a-json-configuration-from-ai-launchpad)
18
19
  - [Using Resource Groups](#using-resource-groups)
19
20
  - [Custom Request Configuration](#custom-request-configuration)
20
21
  - [Custom Destination](#custom-destination)
@@ -326,6 +327,23 @@ const response = await orchestrationClient.chatCompletion({
326
327
  return response.getContent();
327
328
  ```
328
329
 
330
+ ### Using a JSON Configuration from AI Launchpad
331
+
332
+ If you already have an orchestration workflow created in AI Launchpad, you can either download the configuration as a JSON file or copy the JSON string directly to use it with the orchestration client.
333
+
334
+ ```ts
335
+ const jsonConfig = await fs.promises.readFile(
336
+ 'path/to/orchestration-config.json',
337
+ 'utf-8'
338
+ );
339
+ // Alternatively, you can provide the JSON configuration as a plain string in the code directly.
340
+ // const jsonConfig = 'YOUR_JSON_CONFIG'
341
+
342
+ const response = await new OrchestrationClient(jsonConfig).chatCompletion();
343
+
344
+ return response;
345
+ ```
346
+
329
347
  ### Using Resource Groups
330
348
 
331
349
  The resource group can be used as an additional parameter to pick the right orchestration deployment.
@@ -13,11 +13,11 @@ export declare class OrchestrationClient {
13
13
  private destination?;
14
14
  /**
15
15
  * Creates an instance of the orchestration client.
16
- * @param config - Orchestration module configuration.
16
+ * @param config - Orchestration module configuration. This can either be an `OrchestrationModuleConfig` object or a JSON string obtained from AI Launchpad.
17
17
  * @param deploymentConfig - Deployment configuration.
18
18
  * @param destination - The destination to use for the request.
19
19
  */
20
- constructor(config: OrchestrationModuleConfig, deploymentConfig?: ResourceGroupConfig | undefined, destination?: HttpDestinationOrFetchOptions | undefined);
20
+ constructor(config: OrchestrationModuleConfig | string, deploymentConfig?: ResourceGroupConfig | undefined, destination?: HttpDestinationOrFetchOptions | undefined);
21
21
  /**
22
22
  * Creates a completion for the chat messages.
23
23
  * @param prompt - Prompt configuration.
@@ -26,6 +26,10 @@ export declare class OrchestrationClient {
26
26
  */
27
27
  chatCompletion(prompt?: Prompt, requestConfig?: CustomRequestConfig): Promise<OrchestrationResponse>;
28
28
  }
29
+ /**
30
+ * @internal
31
+ */
32
+ export declare function constructCompletionPostRequestFromJson(config: string, prompt?: Prompt): Record<string, any>;
29
33
  /**
30
34
  * @internal
31
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"orchestration-client.d.ts","sourceRoot":"","sources":["../src/orchestration-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EACV,yBAAyB,EACzB,MAAM,EACP,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAEjF;;GAEG;AACH,qBAAa,mBAAmB;IAQ5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC;IATtB;;;;;OAKG;gBAEO,MAAM,EAAE,yBAAyB,EACjC,gBAAgB,CAAC,EAAE,mBAAmB,YAAA,EACtC,WAAW,CAAC,EAAE,6BAA6B,YAAA;IAGrD;;;;;OAKG;IACG,cAAc,CAClB,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,qBAAqB,CAAC;CAmBlC;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,yBAAyB,EACjC,MAAM,CAAC,EAAE,MAAM,GACd,qBAAqB,CA0BvB"}
1
+ {"version":3,"file":"orchestration-client.d.ts","sourceRoot":"","sources":["../src/orchestration-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EACV,yBAAyB,EACzB,MAAM,EACP,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAEjF;;GAEG;AACH,qBAAa,mBAAmB;IAQ5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC;IATtB;;;;;OAKG;gBAEO,MAAM,EAAE,yBAAyB,GAAG,MAAM,EAC1C,gBAAgB,CAAC,EAAE,mBAAmB,YAAA,EACtC,WAAW,CAAC,EAAE,6BAA6B,YAAA;IAGrD;;;;;OAKG;IACG,cAAc,CAClB,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,qBAAqB,CAAC;CAuBlC;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAUrB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,yBAAyB,EACjC,MAAM,CAAC,EAAE,MAAM,GACd,qBAAqB,CA0BvB"}
@@ -10,7 +10,7 @@ export class OrchestrationClient {
10
10
  destination;
11
11
  /**
12
12
  * Creates an instance of the orchestration client.
13
- * @param config - Orchestration module configuration.
13
+ * @param config - Orchestration module configuration. This can either be an `OrchestrationModuleConfig` object or a JSON string obtained from AI Launchpad.
14
14
  * @param deploymentConfig - Deployment configuration.
15
15
  * @param destination - The destination to use for the request.
16
16
  */
@@ -26,7 +26,9 @@ export class OrchestrationClient {
26
26
  * @returns The completion result.
27
27
  */
28
28
  async chatCompletion(prompt, requestConfig) {
29
- const body = constructCompletionPostRequest(this.config, prompt);
29
+ const body = typeof this.config === 'string'
30
+ ? constructCompletionPostRequestFromJson(this.config, prompt)
31
+ : constructCompletionPostRequest(this.config, prompt);
30
32
  const deploymentId = await resolveDeploymentId({
31
33
  scenarioId: 'orchestration',
32
34
  resourceGroup: this.deploymentConfig?.resourceGroup
@@ -38,6 +40,21 @@ export class OrchestrationClient {
38
40
  return new OrchestrationResponse(response);
39
41
  }
40
42
  }
43
+ /**
44
+ * @internal
45
+ */
46
+ export function constructCompletionPostRequestFromJson(config, prompt) {
47
+ try {
48
+ return {
49
+ messages_history: prompt?.messagesHistory || [],
50
+ input_params: prompt?.inputParams || {},
51
+ orchestration_config: JSON.parse(config)
52
+ };
53
+ }
54
+ catch (error) {
55
+ throw new Error(`Could not parse JSON: ${error}`);
56
+ }
57
+ }
41
58
  /**
42
59
  * @internal
43
60
  */
@@ -1 +1 @@
1
- {"version":3,"file":"orchestration-client.js","sourceRoot":"","sources":["../src/orchestration-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAUpE;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAQpB;IACA;IACA;IATV;;;;;OAKG;IACH,YACU,MAAiC,EACjC,gBAAsC,EACtC,WAA2C;QAF3C,WAAM,GAAN,MAAM,CAA2B;QACjC,qBAAgB,GAAh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,MAAM,CAAC,SAAS;iBAC1C,CAAC;aACH;SACF;QACD,GAAG,CAAC,MAAM,EAAE,WAAW,IAAI;YACzB,YAAY,EAAE,MAAM,CAAC,WAAW;SACjC,CAAC;QACF,GAAG,CAAC,MAAM,EAAE,eAAe,IAAI;YAC7B,gBAAgB,EAAE,MAAM,CAAC,eAAe;SACzC,CAAC;KACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ai-sdk/orchestration",
3
- "version": "1.4.1-20241220013116.0",
3
+ "version": "1.4.1-20241221013105.0",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -22,8 +22,8 @@
22
22
  "dependencies": {
23
23
  "@sap-cloud-sdk/http-client": "^3.24.0",
24
24
  "@sap-cloud-sdk/connectivity": "^3.24.0",
25
- "@sap-ai-sdk/core": "^1.4.1-20241220013116.0",
26
- "@sap-ai-sdk/ai-api": "^1.4.1-20241220013116.0"
25
+ "@sap-ai-sdk/core": "^1.4.1-20241221013105.0",
26
+ "@sap-ai-sdk/ai-api": "^1.4.1-20241221013105.0"
27
27
  },
28
28
  "scripts": {
29
29
  "compile": "tsc",