@forge/llm 0.6.0-next.0 → 0.6.0-next.1

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,12 @@
1
1
  # @forge/llm
2
2
 
3
+ ## 0.6.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [16a4b01]
8
+ - @forge/api@7.1.0-next.2
9
+
3
10
  ## 0.6.0-next.0
4
11
 
5
12
  ### Minor Changes
package/out/errors.d.ts CHANGED
@@ -17,13 +17,16 @@ export interface APIErrorResponseDetails {
17
17
  status: number;
18
18
  statusText: string;
19
19
  traceId?: string | null;
20
+ code?: string;
21
+ message: string;
22
+ context?: string | Record<string, unknown>;
20
23
  }
21
24
  export declare class ForgeLlmAPIError extends ForgeLlmError {
22
- responseDetails: APIErrorResponseDetails;
23
- code: string;
24
- message: string;
25
- context: Record<string, unknown>;
26
- constructor(responseDetails: APIErrorResponseDetails, forgeError: ForgeError);
25
+ code?: string;
26
+ status: number;
27
+ statusText: string;
28
+ traceId?: string | null;
29
+ constructor(responseDetails: APIErrorResponseDetails);
27
30
  }
28
31
  export declare class StreamResponseError extends ForgeLlmError {
29
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;I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e,EAAE,uBAAuB;CASrD;AAED,qBAAa,mBAAoB,SAAQ,aAAa;CAAG"}
package/out/errors.js CHANGED
@@ -20,18 +20,18 @@ class PromptValidationError extends ForgeLlmError {
20
20
  }
21
21
  exports.PromptValidationError = PromptValidationError;
22
22
  class ForgeLlmAPIError extends ForgeLlmError {
23
- responseDetails;
24
23
  code;
25
- message;
26
- context;
27
- constructor(responseDetails, forgeError) {
28
- super(forgeError.message);
29
- const { status, statusText, traceId } = responseDetails;
30
- this.responseDetails = { status, statusText, traceId };
31
- const { code, message, context, ...bodyData } = forgeError;
32
- this.code = code || exports.errorCodes.FORGE_LLM_API_ERROR;
33
- this.message = message;
34
- this.context = { ...context, ...bodyData };
24
+ status;
25
+ statusText;
26
+ traceId;
27
+ constructor(responseDetails) {
28
+ const { code, status, statusText, traceId, message } = responseDetails;
29
+ super(message);
30
+ this.name = 'ForgeLlmAPIError';
31
+ this.code = code;
32
+ this.status = status;
33
+ this.traceId = traceId;
34
+ this.statusText = statusText;
35
35
  }
36
36
  }
37
37
  exports.ForgeLlmAPIError = ForgeLlmAPIError;
@@ -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;AAU9F,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAE9D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB1E;AAYD,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;AAU9F,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAE9D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB1E;AAYD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAMnE"}
@@ -18,17 +18,15 @@ async function checkResponseError(response) {
18
18
  const parsedBody = safeGetParsedBody(responseText);
19
19
  const statusText = response.statusText;
20
20
  const traceId = extractTraceId(response);
21
+ const { code, message } = getStructuredForgeError(parsedBody) ?? getUnstructuredForgeError(response, responseText);
21
22
  const responseDetails = {
22
23
  status: response.status,
23
24
  statusText,
24
- traceId
25
+ traceId,
26
+ message: message || text_1.Text.error.unKnownError,
27
+ code
25
28
  };
26
- const structured = getStructuredForgeError(parsedBody);
27
- if (structured) {
28
- throw new errors_1.ForgeLlmAPIError(responseDetails, structured);
29
- }
30
- const unstructured = getUnstructuredForgeError(response, responseText);
31
- throw new errors_1.ForgeLlmAPIError(responseDetails, unstructured);
29
+ throw new errors_1.ForgeLlmAPIError(responseDetails);
32
30
  }
33
31
  exports.checkResponseError = checkResponseError;
34
32
  function getStructuredForgeError(parsedBody) {
@@ -36,8 +34,8 @@ function getStructuredForgeError(parsedBody) {
36
34
  }
37
35
  function getUnstructuredForgeError(response, responseText) {
38
36
  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: {} };
37
+ const message = responseText;
38
+ return { code, message };
41
39
  }
42
40
  function safeGetParsedBody(text) {
43
41
  try {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@forge/llm",
3
- "version": "0.6.0-next.0",
3
+ "version": "0.6.0-next.1",
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": "^7.0.3-next.0"
10
+ "@forge/api": "^7.1.0-next.2"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "20.19.1",
@@ -1,3 +0,0 @@
1
- import { FetchMethod } from '@forge/api';
2
- export declare function getFetchWrapper(): FetchMethod;
3
- //# sourceMappingURL=fetch-wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-wrapper.d.ts","sourceRoot":"","sources":["../src/fetch-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,WAAW,EAAe,MAAM,YAAY,CAAC;AAEjF,wBAAgB,eAAe,IAAI,WAAW,CAc7C"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFetchWrapper = void 0;
4
- const api_1 = require("@forge/api");
5
- function getFetchWrapper() {
6
- const { tracing } = (0, api_1.__getRuntime)();
7
- return async function (path, options) {
8
- const model = path?.split('/').pop();
9
- return await global.__forge_fetch__({ type: 'llm', model: model }, path, {
10
- ...options,
11
- headers: {
12
- ...options?.headers,
13
- 'Content-Type': 'application/json',
14
- 'x-b3-traceid': tracing.traceId,
15
- 'x-b3-spanid': tracing.spanId
16
- }
17
- });
18
- };
19
- }
20
- exports.getFetchWrapper = getFetchWrapper;