smoltalk 0.0.32 → 0.0.34

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.
@@ -42,17 +42,34 @@ export class SmolGoogle extends BaseClient {
42
42
  return { usage, cost };
43
43
  }
44
44
  buildRequest(config) {
45
- const messages = config.messages.map((msg) => msg.toGoogleMessage());
45
+ // Google Gemini only supports "user" and "model" roles in the contents
46
+ // array. System and developer messages must be passed via systemInstruction.
47
+ const systemParts = [];
48
+ const contentMessages = config.messages.filter((msg) => {
49
+ if (msg.role === "system" || msg.role === "developer") {
50
+ systemParts.push(msg.content);
51
+ return false;
52
+ }
53
+ return true;
54
+ });
55
+ const messages = contentMessages.map((msg) => msg.toGoogleMessage());
46
56
  const tools = (config.tools || []).map((tool) => {
47
57
  return zodToGoogleTool(tool.name, tool.schema, {
48
58
  description: tool.description,
49
59
  });
50
60
  });
51
61
  const genConfig = {};
62
+ if (systemParts.length > 0) {
63
+ genConfig.systemInstruction = systemParts.join("\n");
64
+ }
52
65
  if (tools.length > 0) {
53
66
  genConfig.tools = [{ functionDeclarations: tools }];
54
67
  }
55
- if (config.responseFormat) {
68
+ // Google Gemini does not support combining function calling with
69
+ // responseMimeType 'application/json'. When tools are present, skip
70
+ // setting the JSON response format — the BaseClient's textWithRetry
71
+ // will still validate/parse the response against the schema.
72
+ if (config.responseFormat && tools.length === 0) {
56
73
  genConfig.responseMimeType = "application/json";
57
74
  genConfig.responseJsonSchema = config.responseFormat.toJSONSchema();
58
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smoltalk",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "A common interface for LLM APIs",
5
5
  "homepage": "https://github.com/egonSchiele/smoltalk",
6
6
  "scripts": {
@@ -47,4 +47,4 @@
47
47
  "ollama": "^0.6.3",
48
48
  "openai": "^6.15.0"
49
49
  }
50
- }
50
+ }