smoltalk 0.0.47 → 0.0.49
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/dist/clients/google.js
CHANGED
|
@@ -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 &&
|
|
98
|
-
//
|
|
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
|
|
@@ -103,7 +104,11 @@ export class SmolGoogle extends BaseClient {
|
|
|
103
104
|
// make two requests instead
|
|
104
105
|
/*********** TOOL CALL REQUEST ************/
|
|
105
106
|
this.logger.debug("Detected both tool calls and structured response in call to Google Gemini. Making separate request to Google Gemini for tool calls.");
|
|
106
|
-
this.statelogClient?.debug("
|
|
107
|
+
this.statelogClient?.debug("Detected both tool calls and structured response in call to Google Gemini. Making separate request to Google Gemini for tool calls.", {
|
|
108
|
+
contents: request.contents,
|
|
109
|
+
tools: config.tools,
|
|
110
|
+
responseFormat: config.responseFormat,
|
|
111
|
+
});
|
|
107
112
|
const toolRequest = {
|
|
108
113
|
...request,
|
|
109
114
|
config: {
|
|
@@ -118,12 +123,21 @@ export class SmolGoogle extends BaseClient {
|
|
|
118
123
|
}
|
|
119
124
|
if (toolResult.value.toolCalls.length > 0) {
|
|
120
125
|
this.logger.debug("Tool calls detected. Returning tool calls without making second request for structured response.");
|
|
126
|
+
this.statelogClient?.debug("Tool calls detected in Google Gemini response, skipping structured response request", {
|
|
127
|
+
toolCalls: toolResult.value.toolCalls,
|
|
128
|
+
});
|
|
121
129
|
return toolResult;
|
|
122
130
|
}
|
|
123
131
|
if (!toolResult.value.output) {
|
|
132
|
+
this.statelogClient?.debug("No output or tool calls detected in Google Gemini response", {
|
|
133
|
+
response: toolResult.value,
|
|
134
|
+
});
|
|
124
135
|
throw new Error("No output or tool calls detected in Google Gemini response. This should not happen.");
|
|
125
136
|
}
|
|
126
137
|
this.logger.debug("No tool calls detected. Making second request to Google Gemini for structured response.");
|
|
138
|
+
this.statelogClient?.debug("No tool calls detected in Google Gemini response. Making second request for structured response.", {
|
|
139
|
+
response: toolResult.value,
|
|
140
|
+
});
|
|
127
141
|
/*********** STRUCTURED OUTPUT REQUEST ************/
|
|
128
142
|
const message = userMessage(`Please return this output in the specified structured format. Output: ${toolResult.value.output}`);
|
|
129
143
|
const messages = [message.toGoogleMessage()];
|
|
@@ -5,7 +5,13 @@ 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
11
|
if (config.hooks?.onStrategyStart) {
|
|
12
|
+
this.statelogClient?.debug("Calling onStrategyStart hook", {
|
|
13
|
+
strategy: this.toString(),
|
|
14
|
+
});
|
|
9
15
|
config.hooks.onStrategyStart(this, config);
|
|
10
16
|
}
|
|
11
17
|
return this._text({ ...config, strategy: undefined });
|
|
@@ -14,6 +20,9 @@ export class BaseStrategy {
|
|
|
14
20
|
this.statelogClient = config.statelog
|
|
15
21
|
? getStatelogClient(config.statelog)
|
|
16
22
|
: undefined;
|
|
23
|
+
this.statelogClient?.debug("Starting strategy (sync)", {
|
|
24
|
+
strategy: this.toString(),
|
|
25
|
+
});
|
|
17
26
|
return this._textSync({ ...config, strategy: undefined });
|
|
18
27
|
}
|
|
19
28
|
async textStream(config) {
|
|
@@ -54,9 +54,18 @@ export class FallbackStrategy extends BaseStrategy {
|
|
|
54
54
|
});
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
|
+
this.statelogClient?.debug("FallbackStrategy error", {
|
|
58
|
+
failedStrategy: strategy.toString(),
|
|
59
|
+
strategyIndex: i,
|
|
60
|
+
strategies: this.strategies.map((s) => s.toString()),
|
|
61
|
+
error: error.message,
|
|
62
|
+
});
|
|
57
63
|
throw error;
|
|
58
64
|
}
|
|
59
65
|
}
|
|
66
|
+
this.statelogClient?.debug("All strategies in FallbackStrategy failed", {
|
|
67
|
+
strategies: this.strategies.map((s) => s.toString()),
|
|
68
|
+
});
|
|
60
69
|
throw new Error(`All fallback strategies failed.`);
|
|
61
70
|
}
|
|
62
71
|
toJSON() {
|