@sap-ai-sdk/foundation-models 1.0.1-20241002013104.0 → 1.0.1-20241004013114.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 +36 -15
- package/dist/azure-openai/azure-openai-chat-client.d.ts.map +1 -1
- package/dist/azure-openai/azure-openai-chat-client.js +4 -2
- package/dist/azure-openai/azure-openai-chat-client.js.map +1 -1
- package/dist/azure-openai/azure-openai-embedding-client.d.ts.map +1 -1
- package/dist/azure-openai/azure-openai-embedding-client.js +7 -2
- package/dist/azure-openai/azure-openai-embedding-client.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,15 +4,16 @@ This package incorporates generative AI foundation models into your AI activitie
|
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
- [Table of Contents](#table-of-contents)
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Prerequisites](#prerequisites)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Client Initialization](#client-initialization)
|
|
12
|
+
- [Chat Client](#chat-client)
|
|
13
|
+
- [Embedding Client](#embedding-client)
|
|
14
|
+
- [Custom Request Configuration](#custom-request-configuration)
|
|
15
|
+
- [Support, Feedback, Contribution](#support-feedback-contribution)
|
|
16
|
+
- [License](#license)
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -60,14 +61,12 @@ const chatClient = new AzureOpenAiChatClient({
|
|
|
60
61
|
});
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
###
|
|
64
|
-
|
|
65
|
-
The Azure OpenAI client can then be used to send chat completion or embedding requests to models deployed in the SAP generative AI hub.
|
|
66
|
-
|
|
67
|
-
#### Chat Client
|
|
64
|
+
### Chat Client
|
|
68
65
|
|
|
69
66
|
Use the `AzureOpenAiChatClient` to send chat completion requests to an OpenAI model deployed in SAP generative AI hub.
|
|
70
67
|
|
|
68
|
+
The client sends request with Azure OpenAI API version `2024-06-01`.
|
|
69
|
+
|
|
71
70
|
```ts
|
|
72
71
|
import { AzureOpenAiChatClient } from '@sap-ai-sdk/foundation-models';
|
|
73
72
|
|
|
@@ -124,7 +123,7 @@ logger.info(
|
|
|
124
123
|
|
|
125
124
|
Refer to `AzureOpenAiChatCompletionParameters` interface for other parameters that can be passed to the chat completion request.
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
### Embedding Client
|
|
128
127
|
|
|
129
128
|
Use the `AzureOpenAiEmbeddingClient` to send embedding requests to an OpenAI model deployed in SAP generative AI hub.
|
|
130
129
|
|
|
@@ -140,6 +139,28 @@ const response = await embeddingClient.run({
|
|
|
140
139
|
const embedding = response.getEmbedding();
|
|
141
140
|
```
|
|
142
141
|
|
|
142
|
+
### Custom Request Configuration
|
|
143
|
+
|
|
144
|
+
Set custom request configuration in the `requestConfig` parameter when calling the `run()` method of a chat or embedding client.
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const response = await client.run(
|
|
148
|
+
{
|
|
149
|
+
...
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
headers: {
|
|
153
|
+
'x-custom-header': 'custom-value'
|
|
154
|
+
// Add more headers here
|
|
155
|
+
},
|
|
156
|
+
params: {
|
|
157
|
+
// Add more parameters here
|
|
158
|
+
}
|
|
159
|
+
// Add more request configuration here
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
```
|
|
163
|
+
|
|
143
164
|
## Support, Feedback, Contribution
|
|
144
165
|
|
|
145
166
|
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/SAP/ai-sdk-js/issues).
|
|
@@ -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,
|
|
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,KAAK,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAc,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAE/F;;GAEG;AACH,qBAAa,qBAAqB;IAKpB,OAAO,CAAC,eAAe;IAJnC;;;OAGG;gBACiB,eAAe,EAAE,eAAe,CAAC,oBAAoB,CAAC;IAE1E;;;;;OAKG;IACG,GAAG,CACP,IAAI,EAAE,sCAAsC,EAC5C,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,iCAAiC,CAAC;CAiB9C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { executeRequest } from '@sap-ai-sdk/core';
|
|
2
|
-
import { getDeploymentId } from '@sap-ai-sdk/ai-api/internal.js';
|
|
2
|
+
import { getDeploymentId, getResourceGroup } from '@sap-ai-sdk/ai-api/internal.js';
|
|
3
3
|
import { apiVersion } from './model-types.js';
|
|
4
4
|
import { AzureOpenAiChatCompletionResponse } from './azure-openai-chat-completion-response.js';
|
|
5
5
|
/**
|
|
@@ -22,9 +22,11 @@ export class AzureOpenAiChatClient {
|
|
|
22
22
|
*/
|
|
23
23
|
async run(data, requestConfig) {
|
|
24
24
|
const deploymentId = await getDeploymentId(this.modelDeployment, 'azure-openai');
|
|
25
|
+
const resourceGroup = getResourceGroup(this.modelDeployment);
|
|
25
26
|
const response = await executeRequest({
|
|
26
27
|
url: `/inference/deployments/${deploymentId}/chat/completions`,
|
|
27
|
-
apiVersion
|
|
28
|
+
apiVersion,
|
|
29
|
+
resourceGroup
|
|
28
30
|
}, data, requestConfig);
|
|
29
31
|
return new AzureOpenAiChatCompletionResponse(response);
|
|
30
32
|
}
|
|
@@ -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,
|
|
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;AAExC,OAAO,EAAE,UAAU,EAA6B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAE/F;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAKZ;IAJpB;;;OAGG;IACH,YAAoB,eAAsD;QAAtD,oBAAe,GAAf,eAAe,CAAuC;IAAG,CAAC;IAE9E;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,IAA4C,EAC5C,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,mBAAmB;YAC9D,UAAU;YACV,aAAa;SACd,EACD,IAAI,EACJ,aAAa,CACd,CAAC;QACF,OAAO,IAAI,iCAAiC,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -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,
|
|
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,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,EAAc,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE9E;;GAEG;AACH,qBAAa,0BAA0B;IAOnC,OAAO,CAAC,eAAe;IANzB;;;OAGG;gBAGO,eAAe,EAAE,eAAe,CAAC,yBAAyB,CAAC;IAGrE;;;;;OAKG;IACG,GAAG,CACP,IAAI,EAAE,8BAA8B,EACpC,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,4BAA4B,CAAC;CAiBzC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { executeRequest } from '@sap-ai-sdk/core';
|
|
2
|
-
import { getDeploymentId } from '@sap-ai-sdk/ai-api/internal.js';
|
|
2
|
+
import { getDeploymentId, getResourceGroup } from '@sap-ai-sdk/ai-api/internal.js';
|
|
3
3
|
import { AzureOpenAiEmbeddingResponse } from './azure-openai-embedding-response.js';
|
|
4
4
|
import { apiVersion } from './model-types.js';
|
|
5
5
|
/**
|
|
@@ -22,7 +22,12 @@ export class AzureOpenAiEmbeddingClient {
|
|
|
22
22
|
*/
|
|
23
23
|
async run(data, requestConfig) {
|
|
24
24
|
const deploymentId = await getDeploymentId(this.modelDeployment, 'azure-openai');
|
|
25
|
-
const
|
|
25
|
+
const resourceGroup = getResourceGroup(this.modelDeployment);
|
|
26
|
+
const response = await executeRequest({
|
|
27
|
+
url: `/inference/deployments/${deploymentId}/embeddings`,
|
|
28
|
+
apiVersion,
|
|
29
|
+
resourceGroup
|
|
30
|
+
}, data, requestConfig);
|
|
26
31
|
return new AzureOpenAiEmbeddingResponse(response);
|
|
27
32
|
}
|
|
28
33
|
}
|
|
@@ -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,
|
|
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;AAEpF,OAAO,EAAE,UAAU,EAAkC,MAAM,kBAAkB,CAAC;AAE9E;;GAEG;AACH,MAAM,OAAO,0BAA0B;IAO3B;IANV;;;OAGG;IAEH,YACU,eAA2D;QAA3D,oBAAe,GAAf,eAAe,CAA4C;IAClE,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,CACd,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.0.1-
|
|
3
|
+
"version": "1.0.1-20241004013114.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.21.0",
|
|
24
24
|
"@sap-cloud-sdk/util": "^3.21.0",
|
|
25
|
-
"@sap-ai-sdk/
|
|
26
|
-
"@sap-ai-sdk/
|
|
25
|
+
"@sap-ai-sdk/core": "^1.0.1-20241004013114.0",
|
|
26
|
+
"@sap-ai-sdk/ai-api": "^1.0.1-20241004013114.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"compile": "tsc",
|