@adobe/spacecat-shared-gpt-client 1.3.0 → 1.3.2
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/CHANGELOG.md +14 -0
- package/README.md +5 -0
- package/package.json +2 -2
- package/src/clients/firefall-client.js +15 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-gpt-client-v1.3.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-gpt-client-v1.3.1...@adobe/spacecat-shared-gpt-client-v1.3.2) (2024-11-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update external fixes ([#454](https://github.com/adobe/spacecat-shared/issues/454)) ([325cf8d](https://github.com/adobe/spacecat-shared/commit/325cf8dded5fcabadaf7d8fdd510d33aeafd08a7))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-gpt-client-v1.3.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-gpt-client-v1.3.0...@adobe/spacecat-shared-gpt-client-v1.3.1) (2024-11-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* SITES-26948 [Import Assistant] Allow calls to Firefall to use specified ims org id ([#443](https://github.com/adobe/spacecat-shared/issues/443)) ([a63016c](https://github.com/adobe/spacecat-shared/commit/a63016c426ae8a4c0f7f66653e49f1098d466ee8))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-gpt-client-v1.3.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-gpt-client-v1.2.22...@adobe/spacecat-shared-gpt-client-v1.3.0) (2024-11-12)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -10,6 +10,11 @@ To use the `FirefallClient`, you need to configure it with the following paramet
|
|
|
10
10
|
- `FIREFALL_API_KEY`: Your API key for accessing the Firefall API.
|
|
11
11
|
- `FIREFALL_API_CAPABILITY_NAME`: The capability name for the Firefall API.
|
|
12
12
|
|
|
13
|
+
Optionally, you can specify the IMS ORG ID to use when calling the Firefall APIs. If this value is not specified, the IMS_CLIENT_ID (see below) will
|
|
14
|
+
be used for the header's value:
|
|
15
|
+
|
|
16
|
+
- `FIREFALL_IMS_ORG_ID`: The IMS ORG ID to use when calling the Firefall APIs and tracking the request.
|
|
17
|
+
|
|
13
18
|
These parameters can be set through environment variables or passed directly to the `FirefallClient.createFrom` method.
|
|
14
19
|
|
|
15
20
|
Additionally, the configuration for the `@adobe/spacecat-shared-ims-client` library is required to fetch the service access token from the IMS API:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-gpt-client",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - GPT Client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"nock": "13.5.6",
|
|
46
46
|
"sinon": "19.0.2",
|
|
47
47
|
"sinon-chai": "4.0.0",
|
|
48
|
-
"typescript": "5.
|
|
48
|
+
"typescript": "5.7.2"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -50,7 +50,8 @@ export default class FirefallClient {
|
|
|
50
50
|
|
|
51
51
|
const {
|
|
52
52
|
FIREFALL_API_ENDPOINT: apiEndpoint,
|
|
53
|
-
IMS_CLIENT_ID:
|
|
53
|
+
IMS_CLIENT_ID: imsClientId,
|
|
54
|
+
FIREFALL_IMS_ORG_ID: firefallImsOrgId,
|
|
54
55
|
FIREFALL_API_KEY: apiKey,
|
|
55
56
|
FIREFALL_API_POLL_INTERVAL: pollInterval = 2000,
|
|
56
57
|
FIREFALL_API_CAPABILITY_NAME: capabilityName = 'gpt4_32k_completions_capability',
|
|
@@ -69,7 +70,7 @@ export default class FirefallClient {
|
|
|
69
70
|
apiKey,
|
|
70
71
|
capabilityName,
|
|
71
72
|
imsClient,
|
|
72
|
-
imsOrg,
|
|
73
|
+
imsOrg: firefallImsOrgId || imsClientId,
|
|
73
74
|
pollInterval,
|
|
74
75
|
}, log);
|
|
75
76
|
}
|
|
@@ -107,6 +108,12 @@ export default class FirefallClient {
|
|
|
107
108
|
this.log.debug(`${message}: took ${duration}ms`);
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Submit a prompt to the Firefall API.
|
|
113
|
+
* @param body The body of the request.
|
|
114
|
+
* @param path The Firefall API path.
|
|
115
|
+
* @returns {Promise<unknown>}
|
|
116
|
+
*/
|
|
110
117
|
async #submitPrompt(body, path) {
|
|
111
118
|
const apiAuth = await this.#getApiAuth();
|
|
112
119
|
|
|
@@ -184,7 +191,11 @@ export default class FirefallClient {
|
|
|
184
191
|
* @returns {Object} - AI response
|
|
185
192
|
*/
|
|
186
193
|
async fetchChatCompletion(prompt, options = {}) {
|
|
187
|
-
const {
|
|
194
|
+
const {
|
|
195
|
+
imageUrls,
|
|
196
|
+
responseFormat,
|
|
197
|
+
model: llmModel = 'gpt-4-turbo',
|
|
198
|
+
} = options || {};
|
|
188
199
|
const hasImageUrls = imageUrls && imageUrls.length > 0;
|
|
189
200
|
|
|
190
201
|
const getBody = () => {
|
|
@@ -246,10 +257,7 @@ export default class FirefallClient {
|
|
|
246
257
|
const startTime = process.hrtime.bigint();
|
|
247
258
|
const body = getBody();
|
|
248
259
|
|
|
249
|
-
chatSubmissionResponse = await this.#submitPrompt(
|
|
250
|
-
JSON.stringify(body),
|
|
251
|
-
'/v2/chat/completions',
|
|
252
|
-
);
|
|
260
|
+
chatSubmissionResponse = await this.#submitPrompt(JSON.stringify(body), '/v2/chat/completions');
|
|
253
261
|
this.#logDuration('Firefall API Chat Completion call', startTime);
|
|
254
262
|
} catch (error) {
|
|
255
263
|
this.log.error('Error while fetching data from Firefall chat API: ', error.message);
|