smoltalk 0.0.49 → 0.0.51

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.
@@ -157,6 +157,7 @@ export class BaseClient {
157
157
  this.statelogClient?.debug("Request aborted or timed out", {
158
158
  reason: message,
159
159
  timeBudgetMs,
160
+ promptConfig,
160
161
  });
161
162
  return { success: false, error: message };
162
163
  }
@@ -380,6 +381,7 @@ export class BaseClient {
380
381
  this.statelogClient?.debug("Streaming request aborted or timed out", {
381
382
  reason: message,
382
383
  timeBudgetMs,
384
+ newPromptConfig,
383
385
  });
384
386
  yield { type: "timeout", error: message };
385
387
  }
@@ -29,7 +29,7 @@ export declare class StatelogClient {
29
29
  host: string;
30
30
  debugMode: boolean;
31
31
  };
32
- debug(message: string, data: any): Promise<void>;
32
+ debug(message: string, data?: any): Promise<void>;
33
33
  enterNode({ nodeId, data, }: {
34
34
  nodeId: string;
35
35
  data: any;
@@ -38,7 +38,7 @@ export class StatelogClient {
38
38
  debugMode: this.debugMode,
39
39
  };
40
40
  }
41
- async debug(message, data) {
41
+ async debug(message, data = {}) {
42
42
  await this.post({
43
43
  type: "debug",
44
44
  message: message,
@@ -5,13 +5,9 @@ export class BaseStrategy {
5
5
  this.statelogClient = config.statelog
6
6
  ? getStatelogClient(config.statelog)
7
7
  : undefined;
8
- this.statelogClient?.debug("Starting strategy", {
9
- strategy: this.toString(),
10
- });
8
+ this.statelogClient?.debug(`Starting strategy ${this.toString()}`);
11
9
  if (config.hooks?.onStrategyStart) {
12
- this.statelogClient?.debug("Calling onStrategyStart hook", {
13
- strategy: this.toString(),
14
- });
10
+ this.statelogClient?.debug(`Calling onStrategyStart hook for strategy ${this.toString()}`);
15
11
  config.hooks.onStrategyStart(this, config);
16
12
  }
17
13
  return this._text({ ...config, strategy: undefined });
@@ -20,9 +16,7 @@ export class BaseStrategy {
20
16
  this.statelogClient = config.statelog
21
17
  ? getStatelogClient(config.statelog)
22
18
  : undefined;
23
- this.statelogClient?.debug("Starting strategy (sync)", {
24
- strategy: this.toString(),
25
- });
19
+ this.statelogClient?.debug(`Starting strategy (sync) ${this.toString()}`);
26
20
  return this._textSync({ ...config, strategy: undefined });
27
21
  }
28
22
  async textStream(config) {
@@ -27,7 +27,14 @@ export class RaceStrategy extends BaseStrategy {
27
27
  abortSignal: controllers[i].signal,
28
28
  });
29
29
  });
30
+ let winnerIndex = null;
30
31
  return Promise.race(promises.map((p, i) => p.then((result) => {
32
+ if (winnerIndex !== null) {
33
+ // This strategy resolved after the winner (e.g. due to being aborted).
34
+ // Do not attempt to abort other strategies again.
35
+ return result;
36
+ }
37
+ winnerIndex = i;
31
38
  for (let j = 0; j < controllers.length; j++) {
32
39
  if (j !== i) {
33
40
  const logger = getLogger();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smoltalk",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "description": "A common interface for LLM APIs",
5
5
  "homepage": "https://github.com/egonSchiele/smoltalk",
6
6
  "scripts": {