@sap-ai-sdk/orchestration 1.2.1-20241113013102.0 → 1.2.1-20241115013129.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
|
@@ -36,9 +36,12 @@ $ npm install @sap-ai-sdk/orchestration
|
|
|
36
36
|
Alternatively, you can also create deployments using the [SAP AI Launchpad](https://help.sap.com/docs/sap-ai-core/generative-ai-hub/activate-generative-ai-hub-for-sap-ai-launchpad?locale=en-US&q=launchpad).
|
|
37
37
|
- Once the deployment is complete, access the orchestration service via the `deploymentUrl`.
|
|
38
38
|
|
|
39
|
-
> **Accessing the AI Core Service via the SDK
|
|
40
|
-
>
|
|
41
|
-
>
|
|
39
|
+
> **Accessing the AI Core Service via the SDK**
|
|
40
|
+
>
|
|
41
|
+
> The SDK automatically retrieves the `AI Core` service credentials and resolves the access token needed for authentication.
|
|
42
|
+
>
|
|
43
|
+
> - In Cloud Foundry, it's accessed from the `VCAP_SERVICES` environment variable.
|
|
44
|
+
> - In Kubernetes / Kyma environments, you have to mount the service binding as a secret instead, for more information refer to [this documentation](https://www.npmjs.com/package/@sap/xsenv#usage-in-kubernetes).
|
|
42
45
|
|
|
43
46
|
## Orchestration Service
|
|
44
47
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestration-response.d.ts","sourceRoot":"","sources":["../src/orchestration-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orchestration-response.d.ts","sourceRoot":"","sources":["../src/orchestration-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACX,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,qBAAa,qBAAqB;aAKJ,WAAW,EAAE,YAAY;IAJrD;;OAEG;IACH,SAAgB,IAAI,EAAE,sBAAsB,CAAC;gBACjB,WAAW,EAAE,YAAY;IAIrD;;;OAGG;IACH,aAAa,IAAI,UAAU;IAG3B;;;;OAIG;IACH,eAAe,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS;IAIpD;;;;;OAKG;IACH,UAAU,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS;IAa/C,OAAO,CAAC,UAAU;CAGnB"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { createLogger } from '@sap-cloud-sdk/util';
|
|
2
|
-
const logger = createLogger({
|
|
3
|
-
package: 'orchestration',
|
|
4
|
-
messageContext: 'orchestration-response'
|
|
5
|
-
});
|
|
6
1
|
/**
|
|
7
2
|
* Representation of an orchestration response.
|
|
8
3
|
*/
|
|
@@ -29,8 +24,7 @@ export class OrchestrationResponse {
|
|
|
29
24
|
* @returns The finish reason.
|
|
30
25
|
*/
|
|
31
26
|
getFinishReason(choiceIndex = 0) {
|
|
32
|
-
this.
|
|
33
|
-
return this.getChoices()[choiceIndex]?.finish_reason;
|
|
27
|
+
return this.getChoices().find(c => c.index === choiceIndex)?.finish_reason;
|
|
34
28
|
}
|
|
35
29
|
/**
|
|
36
30
|
* Parses the orchestration response and returns the content.
|
|
@@ -39,20 +33,15 @@ export class OrchestrationResponse {
|
|
|
39
33
|
* @returns The message content.
|
|
40
34
|
*/
|
|
41
35
|
getContent(choiceIndex = 0) {
|
|
42
|
-
this.
|
|
43
|
-
if (
|
|
44
|
-
|
|
36
|
+
const choice = this.getChoices().find(c => c.index === choiceIndex);
|
|
37
|
+
if (choice?.message?.content === '' &&
|
|
38
|
+
choice?.finish_reason === 'content_filter') {
|
|
45
39
|
throw new Error('Content generated by the LLM was filtered by the output filter. Please try again with a different prompt or filter configuration.');
|
|
46
40
|
}
|
|
47
|
-
return
|
|
41
|
+
return choice?.message?.content;
|
|
48
42
|
}
|
|
49
43
|
getChoices() {
|
|
50
44
|
return this.data.orchestration_result.choices;
|
|
51
45
|
}
|
|
52
|
-
logInvalidChoiceIndex(choiceIndex) {
|
|
53
|
-
if (choiceIndex < 0 || choiceIndex >= this.getChoices().length) {
|
|
54
|
-
logger.error(`Choice index ${choiceIndex} is out of bounds.`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
46
|
}
|
|
58
47
|
//# sourceMappingURL=orchestration-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestration-response.js","sourceRoot":"","sources":["../src/orchestration-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orchestration-response.js","sourceRoot":"","sources":["../src/orchestration-response.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAKJ;IAJ5B;;OAEG;IACa,IAAI,CAAyB;IAC7C,YAA4B,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;QACnD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;IAC9C,CAAC;IACD;;;;OAIG;IACH,eAAe,CAAC,WAAW,GAAG,CAAC;QAC7B,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,EAAE,aAAa,CAAC;IAC7E,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,WAAW,GAAG,CAAC;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC;QACpE,IACE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE;YAC/B,MAAM,EAAE,aAAa,KAAK,gBAAgB,EAC1C,CAAC;YACD,MAAM,IAAI,KAAK,CACb,mIAAmI,CACpI,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;IAClC,CAAC;IAEO,UAAU;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;IAChD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ai-sdk/orchestration",
|
|
3
|
-
"version": "1.2.1-
|
|
3
|
+
"version": "1.2.1-20241115013129.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@sap-cloud-sdk/http-client": "^3.22.2",
|
|
24
|
-
"@sap-
|
|
25
|
-
"@sap-ai-sdk/
|
|
26
|
-
"@sap-ai-sdk/ai-api": "^1.2.1-20241113013102.0"
|
|
24
|
+
"@sap-ai-sdk/core": "^1.2.1-20241115013129.0",
|
|
25
|
+
"@sap-ai-sdk/ai-api": "^1.2.1-20241115013129.0"
|
|
27
26
|
},
|
|
28
27
|
"scripts": {
|
|
29
28
|
"compile": "tsc",
|