@forge/llm 0.2.0-next.4 → 0.2.0-next.5-experimental-ec29181

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @forge/llm
2
2
 
3
+ ## 0.2.0-next.5-experimental-ec29181
4
+
5
+ ### Minor Changes
6
+
7
+ - 4adf05c: Add trace Id
8
+ - 4f53a62: Add support for 'usage' attribute in the chat's response object
9
+ - 7c086a7: Handle unstructured ForgeError message
10
+
11
+ ### Patch Changes
12
+
13
+ - 9e49ce9: Excluded test files
14
+ - Updated dependencies [def4ec3]
15
+ - @forge/api@6.3.0-next.2-experimental-ec29181
16
+
17
+ ## 0.2.0-next.5
18
+
19
+ ### Minor Changes
20
+
21
+ - 7c086a7: Handle unstructured ForgeError message
22
+
3
23
  ## 0.2.0-next.4
4
24
 
5
25
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/utils/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,UAAU,EAAoB,MAAM,WAAW,CAAC;AAE9F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQzC,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAE9D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB7E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAMnE"}
1
+ {"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/utils/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,UAAU,EAAoB,MAAM,WAAW,CAAC;AAE9F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQzC,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAE9D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB7E;AAYD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAMnE"}
@@ -23,16 +23,22 @@ async function checkResponseError(response) {
23
23
  statusText,
24
24
  traceId
25
25
  };
26
- if (parsedBody && isForgeError(parsedBody)) {
27
- throw new errors_1.ForgeLlmAPIError(responseDetails, parsedBody);
26
+ const structured = getStructuredForgeError(parsedBody);
27
+ if (structured) {
28
+ throw new errors_1.ForgeLlmAPIError(responseDetails, structured);
28
29
  }
29
- throw new errors_1.ForgeLlmAPIError(responseDetails, {
30
- code: errors_1.errorCodes.UNKNOWN_ERROR,
31
- message: text_1.Text.error.unKnownError,
32
- context: { responseText }
33
- });
30
+ const unstructured = getUnstructuredForgeError(response, responseText);
31
+ throw new errors_1.ForgeLlmAPIError(responseDetails, unstructured);
34
32
  }
35
33
  exports.checkResponseError = checkResponseError;
34
+ function getStructuredForgeError(parsedBody) {
35
+ return parsedBody && isForgeError(parsedBody) ? parsedBody : undefined;
36
+ }
37
+ function getUnstructuredForgeError(response, responseText) {
38
+ const code = response.headers.get('forge-proxy-error') ?? errors_1.errorCodes.UNKNOWN_ERROR;
39
+ const message = responseText || text_1.Text.error.unKnownError;
40
+ return { code, message, context: {} };
41
+ }
36
42
  function safeGetParsedBody(text) {
37
43
  try {
38
44
  return JSON.parse(text);
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@forge/llm",
3
- "version": "0.2.0-next.4",
3
+ "version": "0.2.0-next.5-experimental-ec29181",
4
4
  "description": "Forge LLM SDK",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
7
7
  "author": "Atlassian",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "dependencies": {
10
- "@forge/api": "^6.3.0-next.2"
10
+ "@forge/api": "^6.3.0-next.2-experimental-ec29181"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "20.19.1",