smoltalk 0.15.0 → 0.15.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.
@@ -82,6 +82,7 @@ export class AssistantMessage extends BaseMessage {
82
82
  thinkingBlocks: this._thinkingBlocks,
83
83
  usage: this._usage,
84
84
  cost: this._cost,
85
+ rawData: this._rawData,
85
86
  };
86
87
  }
87
88
  static fromJSON(json) {
@@ -39,6 +39,7 @@ export class DeveloperMessage extends BaseMessage {
39
39
  role: this.role,
40
40
  content: this._content,
41
41
  name: this.name,
42
+ rawData: this._rawData,
42
43
  };
43
44
  }
44
45
  static fromJSON(json) {
@@ -39,6 +39,7 @@ export class SystemMessage extends BaseMessage {
39
39
  role: this.role,
40
40
  content: this._content,
41
41
  name: this.name,
42
+ rawData: this._rawData,
42
43
  };
43
44
  }
44
45
  static fromJSON(json) {
@@ -47,6 +47,7 @@ export class ToolMessage extends BaseMessage {
47
47
  content: this._content,
48
48
  name: this.name,
49
49
  tool_call_id: this.tool_call_id,
50
+ rawData: this._rawData,
50
51
  };
51
52
  }
52
53
  static fromJSON(json) {
@@ -53,6 +53,7 @@ export class UserMessage extends BaseMessage {
53
53
  role: this.role,
54
54
  content: serializeUserContentForJSON(this._content),
55
55
  name: this.name,
56
+ rawData: this._rawData,
56
57
  };
57
58
  }
58
59
  static fromJSON(json) {
package/dist/decide.js CHANGED
@@ -190,7 +190,9 @@ export async function decide(state, questions, config) {
190
190
  }
191
191
  const text = await response.text();
192
192
  if (!response.ok) {
193
- return failure(`Decision request failed with status ${response.status}: ${text}`);
193
+ return failure(`Decision request failed with status ${response.status}: ${text}`, {
194
+ status: response.status,
195
+ });
194
196
  }
195
197
  let body;
196
198
  try {
@@ -5,8 +5,13 @@ export type Success<T> = {
5
5
  export type Failure = {
6
6
  success: false;
7
7
  error: string;
8
+ /** The HTTP status of the provider response, when the failure came from
9
+ * one. Lets a caller classify a 429 or a 5xx without parsing `error`. */
10
+ status?: number;
8
11
  };
9
12
  export type Result<T> = Success<T> | Failure;
10
13
  export declare function success<T>(value: T): Success<T>;
11
- export declare function failure(error: string): Failure;
14
+ export declare function failure(error: string, fields?: {
15
+ status?: number;
16
+ }): Failure;
12
17
  export declare function mergeResults<T>(results: Result<T>[]): Result<T[]>;
@@ -1,8 +1,11 @@
1
1
  export function success(value) {
2
2
  return { success: true, value };
3
3
  }
4
- export function failure(error) {
5
- return { success: false, error };
4
+ export function failure(error, fields) {
5
+ if (fields?.status === undefined) {
6
+ return { success: false, error };
7
+ }
8
+ return { success: false, error, status: fields.status };
6
9
  }
7
10
  export function mergeResults(results) {
8
11
  const values = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smoltalk",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "A common interface for LLM APIs",
5
5
  "homepage": "https://github.com/egonSchiele/smoltalk",
6
6
  "files": [