@sap-ai-sdk/foundation-models 1.4.1-20241213013144.0 → 1.4.1-20241214013128.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 +16 -2
- package/dist/azure-openai/azure-openai-chat-client.d.ts +4 -1
- package/dist/azure-openai/azure-openai-chat-client.d.ts.map +1 -1
- package/dist/azure-openai/azure-openai-chat-client.js +5 -2
- package/dist/azure-openai/azure-openai-chat-client.js.map +1 -1
- package/dist/azure-openai/azure-openai-embedding-client.d.ts +3 -1
- package/dist/azure-openai/azure-openai-embedding-client.d.ts.map +1 -1
- package/dist/azure-openai/azure-openai-embedding-client.js +4 -2
- package/dist/azure-openai/azure-openai-embedding-client.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -4,9 +4,8 @@ SAP Cloud SDK for AI is the official Software Development Kit (SDK) for **SAP AI
|
|
|
4
4
|
|
|
5
5
|
This package incorporates generative AI foundation models into your AI activities in SAP AI Core and SAP AI Launchpad.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### Table of Contents
|
|
8
8
|
|
|
9
|
-
- [Table of Contents](#table-of-contents)
|
|
10
9
|
- [Installation](#installation)
|
|
11
10
|
- [Prerequisites](#prerequisites)
|
|
12
11
|
- [Relationship between Models and Deployment ID](#relationship-between-models-and-deployment-id)
|
|
@@ -15,6 +14,7 @@ This package incorporates generative AI foundation models into your AI activitie
|
|
|
15
14
|
- [Azure OpenAI Chat Client](#azure-openai-chat-client)
|
|
16
15
|
- [Azure OpenAI Embedding Client](#azure-openai-embedding-client)
|
|
17
16
|
- [Custom Request Configuration](#custom-request-configuration)
|
|
17
|
+
- [Custom Destination](#custom-destination)
|
|
18
18
|
- [Local Testing](#local-testing)
|
|
19
19
|
- [Support, Feedback, Contribution](#support-feedback-contribution)
|
|
20
20
|
- [License](#license)
|
|
@@ -261,6 +261,20 @@ const response = await client.run(
|
|
|
261
261
|
);
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
+
### Custom Destination
|
|
265
|
+
|
|
266
|
+
When initializing the `AzureOpenAiChatClient` and `AzureOpenAiEmbeddingClient` clients, it is possible to provide a custom destination.
|
|
267
|
+
For example, when targeting a destination with the name `my-destination`, the following code can be used:
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
const client = await new AzureOpenAiChatClient('gpt-35-turbo', {
|
|
271
|
+
destinationName: 'my-destination'
|
|
272
|
+
});
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
By default, the fetched destination is cached.
|
|
276
|
+
To disable caching, set the `useCache` parameter to `false` together with the `destinationName` parameter.
|
|
277
|
+
|
|
264
278
|
## Local Testing
|
|
265
279
|
|
|
266
280
|
For local testing instructions, refer to this [section](https://github.com/SAP/ai-sdk-js/blob/main/README.md#local-testing).
|
|
@@ -5,16 +5,19 @@ import { AzureOpenAiChatCompletionResponse } from './azure-openai-chat-completio
|
|
|
5
5
|
import { AzureOpenAiChatCompletionStreamResponse } from './azure-openai-chat-completion-stream-response.js';
|
|
6
6
|
import type { AzureOpenAiChatCompletionStreamChunkResponse } from './azure-openai-chat-completion-stream-chunk-response.js';
|
|
7
7
|
import type { AzureOpenAiCreateChatCompletionRequest } from './client/inference/schema/index.js';
|
|
8
|
+
import type { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
|
|
8
9
|
/**
|
|
9
10
|
* Azure OpenAI client for chat completion.
|
|
10
11
|
*/
|
|
11
12
|
export declare class AzureOpenAiChatClient {
|
|
12
13
|
private modelDeployment;
|
|
14
|
+
private destination?;
|
|
13
15
|
/**
|
|
14
16
|
* Creates an instance of the Azure OpenAI chat client.
|
|
15
17
|
* @param modelDeployment - This configuration is used to retrieve a deployment. Depending on the configuration use either the given deployment ID or the model name to retrieve matching deployments. If model and deployment ID are given, the model is verified against the deployment.
|
|
18
|
+
* @param destination - The destination to use for the request.
|
|
16
19
|
*/
|
|
17
|
-
constructor(modelDeployment: ModelDeployment<AzureOpenAiChatModel
|
|
20
|
+
constructor(modelDeployment: ModelDeployment<AzureOpenAiChatModel>, destination?: HttpDestinationOrFetchOptions | undefined);
|
|
18
21
|
/**
|
|
19
22
|
* Creates a completion for the chat messages.
|
|
20
23
|
* @param data - The input parameters for the chat completion.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-openai-chat-client.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAc,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,uCAAuC,EAAE,MAAM,mDAAmD,CAAC;AAE5G,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,yDAAyD,CAAC;AAE5H,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"azure-openai-chat-client.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAc,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,uCAAuC,EAAE,MAAM,mDAAmD,CAAC;AAE5G,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,yDAAyD,CAAC;AAE5H,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAEjF;;GAEG;AACH,qBAAa,qBAAqB;IAO9B,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,WAAW,CAAC;IAPtB;;;;OAIG;gBAEO,eAAe,EAAE,eAAe,CAAC,oBAAoB,CAAC,EACtD,WAAW,CAAC,EAAE,6BAA6B,YAAA;IAGrD;;;;;OAKG;IACG,GAAG,CACP,IAAI,EAAE,sCAAsC,EAC5C,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,iCAAiC,CAAC;IAK7C;;;;;;OAMG;IACG,MAAM,CACV,IAAI,EAAE,sCAAsC,EAC5C,UAAU,kBAAwB,EAClC,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CACR,uCAAuC,CAAC,4CAA4C,CAAC,CACtF;YAUa,cAAc;YAqBd,YAAY;CAqB3B"}
|
|
@@ -9,12 +9,15 @@ import { AzureOpenAiChatCompletionStream } from './azure-openai-chat-completion-
|
|
|
9
9
|
*/
|
|
10
10
|
export class AzureOpenAiChatClient {
|
|
11
11
|
modelDeployment;
|
|
12
|
+
destination;
|
|
12
13
|
/**
|
|
13
14
|
* Creates an instance of the Azure OpenAI chat client.
|
|
14
15
|
* @param modelDeployment - This configuration is used to retrieve a deployment. Depending on the configuration use either the given deployment ID or the model name to retrieve matching deployments. If model and deployment ID are given, the model is verified against the deployment.
|
|
16
|
+
* @param destination - The destination to use for the request.
|
|
15
17
|
*/
|
|
16
|
-
constructor(modelDeployment) {
|
|
18
|
+
constructor(modelDeployment, destination) {
|
|
17
19
|
this.modelDeployment = modelDeployment;
|
|
20
|
+
this.destination = destination;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Creates a completion for the chat messages.
|
|
@@ -48,7 +51,7 @@ export class AzureOpenAiChatClient {
|
|
|
48
51
|
url: `/inference/deployments/${deploymentId}/chat/completions`,
|
|
49
52
|
apiVersion,
|
|
50
53
|
resourceGroup
|
|
51
|
-
}, data, requestConfig);
|
|
54
|
+
}, data, requestConfig, this.destination);
|
|
52
55
|
}
|
|
53
56
|
async createStream(data, controller, requestConfig) {
|
|
54
57
|
const response = await this.executeRequest({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-openai-chat-client.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAA6B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,uCAAuC,EAAE,MAAM,mDAAmD,CAAC;AAC5G,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"azure-openai-chat-client.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAA6B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,uCAAuC,EAAE,MAAM,mDAAmD,CAAC;AAC5G,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAM3F;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAOtB;IACA;IAPV;;;;OAIG;IACH,YACU,eAAsD,EACtD,WAA2C;QAD3C,oBAAe,GAAf,eAAe,CAAuC;QACtD,gBAAW,GAAX,WAAW,CAAgC;IAClD,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,IAA4C,EAC5C,aAAmC;QA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,YAAY,EAAE,QAAQ;YACtB,MAAM,EAAE,UAAU,CAAC,MAAM;SAC1B,CACF,CAAC;QACF,OAAO,+BAA+B,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -3,16 +3,18 @@ import { type ModelDeployment } from '@sap-ai-sdk/ai-api/internal.js';
|
|
|
3
3
|
import { AzureOpenAiEmbeddingResponse } from './azure-openai-embedding-response.js';
|
|
4
4
|
import { type AzureOpenAiEmbeddingModel } from './model-types.js';
|
|
5
5
|
import type { AzureOpenAiEmbeddingParameters } from './azure-openai-embedding-types.js';
|
|
6
|
+
import type { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
|
|
6
7
|
/**
|
|
7
8
|
* Azure OpenAI client for embeddings.
|
|
8
9
|
*/
|
|
9
10
|
export declare class AzureOpenAiEmbeddingClient {
|
|
10
11
|
private modelDeployment;
|
|
12
|
+
private destination?;
|
|
11
13
|
/**
|
|
12
14
|
* Creates an instance of the Azure OpenAI embedding client.
|
|
13
15
|
* @param modelDeployment - This configuration is used to retrieve a deployment. Depending on the configuration use either the given deployment ID or the model name to retrieve matching deployments. If model and deployment ID are given, the model is verified against the deployment.
|
|
14
16
|
*/
|
|
15
|
-
constructor(modelDeployment: ModelDeployment<AzureOpenAiEmbeddingModel
|
|
17
|
+
constructor(modelDeployment: ModelDeployment<AzureOpenAiEmbeddingModel>, destination?: HttpDestinationOrFetchOptions | undefined);
|
|
16
18
|
/**
|
|
17
19
|
* Creates an embedding vector representing the given text.
|
|
18
20
|
* @param data - The text to embed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-openai-embedding-client.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-embedding-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAc,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"azure-openai-embedding-client.d.ts","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-embedding-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAc,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAEjF;;GAEG;AACH,qBAAa,0BAA0B;IAOnC,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,WAAW,CAAC;IAPtB;;;OAGG;gBAGO,eAAe,EAAE,eAAe,CAAC,yBAAyB,CAAC,EAC3D,WAAW,CAAC,EAAE,6BAA6B,YAAA;IAGrD;;;;;OAKG;IACG,GAAG,CACP,IAAI,EAAE,8BAA8B,EACpC,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,4BAA4B,CAAC;CAkBzC"}
|
|
@@ -7,12 +7,14 @@ import { apiVersion } from './model-types.js';
|
|
|
7
7
|
*/
|
|
8
8
|
export class AzureOpenAiEmbeddingClient {
|
|
9
9
|
modelDeployment;
|
|
10
|
+
destination;
|
|
10
11
|
/**
|
|
11
12
|
* Creates an instance of the Azure OpenAI embedding client.
|
|
12
13
|
* @param modelDeployment - This configuration is used to retrieve a deployment. Depending on the configuration use either the given deployment ID or the model name to retrieve matching deployments. If model and deployment ID are given, the model is verified against the deployment.
|
|
13
14
|
*/
|
|
14
|
-
constructor(modelDeployment) {
|
|
15
|
+
constructor(modelDeployment, destination) {
|
|
15
16
|
this.modelDeployment = modelDeployment;
|
|
17
|
+
this.destination = destination;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Creates an embedding vector representing the given text.
|
|
@@ -27,7 +29,7 @@ export class AzureOpenAiEmbeddingClient {
|
|
|
27
29
|
url: `/inference/deployments/${deploymentId}/embeddings`,
|
|
28
30
|
apiVersion,
|
|
29
31
|
resourceGroup
|
|
30
|
-
}, data, requestConfig);
|
|
32
|
+
}, data, requestConfig, this.destination);
|
|
31
33
|
return new AzureOpenAiEmbeddingResponse(response);
|
|
32
34
|
}
|
|
33
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-openai-embedding-client.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-embedding-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAkC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"azure-openai-embedding-client.js","sourceRoot":"","sources":["../../src/azure-openai/azure-openai-embedding-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAkC,MAAM,kBAAkB,CAAC;AAI9E;;GAEG;AACH,MAAM,OAAO,0BAA0B;IAO3B;IACA;IAPV;;;OAGG;IAEH,YACU,eAA2D,EAC3D,WAA2C;QAD3C,oBAAe,GAAf,eAAe,CAA4C;QAC3D,gBAAW,GAAX,WAAW,CAAgC;IAClD,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,IAAoC,EACpC,aAAmC;QAEnC,MAAM,YAAY,GAAG,MAAM,eAAe,CACxC,IAAI,CAAC,eAAe,EACpB,cAAc,CACf,CAAC;QACF,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC;YACE,GAAG,EAAE,0BAA0B,YAAY,aAAa;YACxD,UAAU;YACV,aAAa;SACd,EACD,IAAI,EACJ,aAAa,EACb,IAAI,CAAC,WAAW,CACjB,CAAC;QACF,OAAO,IAAI,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ai-sdk/foundation-models",
|
|
3
|
-
"version": "1.4.1-
|
|
3
|
+
"version": "1.4.1-20241214013128.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@sap-cloud-sdk/http-client": "^3.24.0",
|
|
24
24
|
"@sap-cloud-sdk/util": "^3.24.0",
|
|
25
|
-
"@sap-
|
|
26
|
-
"@sap-ai-sdk/
|
|
25
|
+
"@sap-cloud-sdk/connectivity": "^3.24.0",
|
|
26
|
+
"@sap-ai-sdk/ai-api": "^1.4.1-20241214013128.0",
|
|
27
|
+
"@sap-ai-sdk/core": "^1.4.1-20241214013128.0"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
30
|
"compile": "tsc",
|