@sap-ai-sdk/foundation-models 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 +6 -3
- package/dist/azure-openai/azure-openai-chat-completion-response.d.ts +1 -2
- package/dist/azure-openai/azure-openai-chat-completion-response.d.ts.map +1 -1
- package/dist/azure-openai/azure-openai-chat-completion-response.js +3 -14
- package/dist/azure-openai/azure-openai-chat-completion-response.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,9 +35,12 @@ $ npm install @sap-ai-sdk/foundation-models
|
|
|
35
35
|
Deployment can be set up for each model and model version, as well as a resource group.
|
|
36
36
|
- Once a deployment is complete, access the model via the `deploymentUrl`.
|
|
37
37
|
|
|
38
|
-
> **Accessing the AI Core Service via the SDK
|
|
39
|
-
>
|
|
40
|
-
>
|
|
38
|
+
> **Accessing the AI Core Service via the SDK**
|
|
39
|
+
>
|
|
40
|
+
> The SDK automatically retrieves the `AI Core` service credentials and resolves the access token needed for authentication.
|
|
41
|
+
>
|
|
42
|
+
> - In Cloud Foundry, it's accessed from the `VCAP_SERVICES` environment variable.
|
|
43
|
+
> - 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).
|
|
41
44
|
|
|
42
45
|
## Relationship between Models and Deployment ID
|
|
43
46
|
|
|
@@ -20,13 +20,12 @@ export declare class AzureOpenAiChatCompletionResponse {
|
|
|
20
20
|
* @param choiceIndex - The index of the choice to parse.
|
|
21
21
|
* @returns The finish reason.
|
|
22
22
|
*/
|
|
23
|
-
getFinishReason(choiceIndex?: number):
|
|
23
|
+
getFinishReason(choiceIndex?: number): string | undefined;
|
|
24
24
|
/**
|
|
25
25
|
* Parses the Azure OpenAI response and returns the content.
|
|
26
26
|
* @param choiceIndex - The index of the choice to parse.
|
|
27
27
|
* @returns The message content.
|
|
28
28
|
*/
|
|
29
29
|
getContent(choiceIndex?: number): string | undefined | null;
|
|
30
|
-
private logInvalidChoiceIndex;
|
|
31
30
|
}
|
|
32
31
|
//# sourceMappingURL=azure-openai-chat-completion-response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-openai-chat-completion-response.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"azure-openai-chat-completion-response.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,oCAAoC,CAAC;AAElG;;GAEG;AACH,qBAAa,iCAAiC;aAKhB,WAAW,EAAE,YAAY;IAJrD;;OAEG;IACH,SAAgB,IAAI,EAAE,uCAAuC,CAAC;gBAClC,WAAW,EAAE,YAAY;IAIrD;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;IAItC;;;;OAIG;IACH,eAAe,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS;IAIpD;;;;OAIG;IACH,UAAU,CAAC,WAAW,SAAI,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI;CAIvD"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { createLogger } from '@sap-cloud-sdk/util';
|
|
2
|
-
const logger = createLogger({
|
|
3
|
-
package: 'foundation-models',
|
|
4
|
-
messageContext: 'azure-openai-chat-completion-response'
|
|
5
|
-
});
|
|
6
1
|
/**
|
|
7
2
|
* Azure OpenAI chat completion response.
|
|
8
3
|
*/
|
|
@@ -29,8 +24,7 @@ export class AzureOpenAiChatCompletionResponse {
|
|
|
29
24
|
* @returns The finish reason.
|
|
30
25
|
*/
|
|
31
26
|
getFinishReason(choiceIndex = 0) {
|
|
32
|
-
this.
|
|
33
|
-
return this.data.choices[choiceIndex]?.finish_reason;
|
|
27
|
+
return this.data.choices.find(c => c.index === choiceIndex)?.finish_reason;
|
|
34
28
|
}
|
|
35
29
|
/**
|
|
36
30
|
* Parses the Azure OpenAI response and returns the content.
|
|
@@ -38,13 +32,8 @@ export class AzureOpenAiChatCompletionResponse {
|
|
|
38
32
|
* @returns The message content.
|
|
39
33
|
*/
|
|
40
34
|
getContent(choiceIndex = 0) {
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
logInvalidChoiceIndex(choiceIndex) {
|
|
45
|
-
if (choiceIndex < 0 || choiceIndex >= this.data.choices.length) {
|
|
46
|
-
logger.error(`Choice index ${choiceIndex} is out of bounds.`);
|
|
47
|
-
}
|
|
35
|
+
return this.data.choices.find(c => c.index === choiceIndex)?.message
|
|
36
|
+
?.content;
|
|
48
37
|
}
|
|
49
38
|
}
|
|
50
39
|
//# sourceMappingURL=azure-openai-chat-completion-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-openai-chat-completion-response.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"azure-openai-chat-completion-response.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-completion-response.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,iCAAiC;IAKhB;IAJ5B;;OAEG;IACa,IAAI,CAA0C;IAC9D,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,KAAK,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,WAAW,GAAG,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,EAAE,aAAa,CAAC;IAC7E,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,WAAW,GAAG,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,EAAE,OAAO;YAClE,EAAE,OAAO,CAAC;IACd,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ai-sdk/foundation-models",
|
|
3
|
-
"version": "1.2.1-
|
|
3
|
+
"version": "1.2.1-20241115013129.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.22.2",
|
|
24
24
|
"@sap-cloud-sdk/util": "^3.22.2",
|
|
25
|
-
"@sap-ai-sdk/ai-api": "^1.2.1-
|
|
26
|
-
"@sap-ai-sdk/core": "^1.2.1-
|
|
25
|
+
"@sap-ai-sdk/ai-api": "^1.2.1-20241115013129.0",
|
|
26
|
+
"@sap-ai-sdk/core": "^1.2.1-20241115013129.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"compile": "tsc",
|