smoltalk 0.0.48 → 0.0.50

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.
@@ -94,8 +94,9 @@ export class SmolGoogle extends BaseClient {
94
94
  }
95
95
  const hasTools = config.tools && config.tools.length > 0;
96
96
  const hasStructuredResponse = !!config.responseFormat;
97
- if (!hasTools && !hasStructuredResponse) {
98
- // If there are no tools or structured response, we can make a single request and return immediately
97
+ if (!(hasTools && hasStructuredResponse)) {
98
+ // Unless we have both tools and structured response,
99
+ // we can make a single request and return immediately
99
100
  return this.__textSync(request);
100
101
  }
101
102
  // Google Gemini does not support combining function calling with
@@ -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.48",
3
+ "version": "0.0.50",
4
4
  "description": "A common interface for LLM APIs",
5
5
  "homepage": "https://github.com/egonSchiele/smoltalk",
6
6
  "scripts": {