@core-ai/google-genai 0.6.1 → 0.7.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.
package/dist/index.d.ts CHANGED
@@ -20,41 +20,19 @@ type GoogleReasoningMetadata = {
20
20
  };
21
21
 
22
22
  declare const googleGenerateProviderOptionsSchema: z.ZodObject<{
23
- stopSequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
23
+ stopSequences: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
24
  frequencyPenalty: z.ZodOptional<z.ZodNumber>;
25
25
  presencePenalty: z.ZodOptional<z.ZodNumber>;
26
26
  seed: z.ZodOptional<z.ZodNumber>;
27
27
  topK: z.ZodOptional<z.ZodNumber>;
28
- }, "strict", z.ZodTypeAny, {
29
- stopSequences?: string[] | undefined;
30
- frequencyPenalty?: number | undefined;
31
- presencePenalty?: number | undefined;
32
- seed?: number | undefined;
33
- topK?: number | undefined;
34
- }, {
35
- stopSequences?: string[] | undefined;
36
- frequencyPenalty?: number | undefined;
37
- presencePenalty?: number | undefined;
38
- seed?: number | undefined;
39
- topK?: number | undefined;
40
- }>;
28
+ }, z.core.$strict>;
41
29
  type GoogleGenerateProviderOptions = z.infer<typeof googleGenerateProviderOptionsSchema>;
42
30
  declare const googleEmbedProviderOptionsSchema: z.ZodObject<{
43
31
  taskType: z.ZodOptional<z.ZodString>;
44
32
  title: z.ZodOptional<z.ZodString>;
45
33
  mimeType: z.ZodOptional<z.ZodString>;
46
34
  autoTruncate: z.ZodOptional<z.ZodBoolean>;
47
- }, "strict", z.ZodTypeAny, {
48
- taskType?: string | undefined;
49
- title?: string | undefined;
50
- mimeType?: string | undefined;
51
- autoTruncate?: boolean | undefined;
52
- }, {
53
- taskType?: string | undefined;
54
- title?: string | undefined;
55
- mimeType?: string | undefined;
56
- autoTruncate?: boolean | undefined;
57
- }>;
35
+ }, z.core.$strict>;
58
36
  type GoogleEmbedProviderOptions = z.infer<typeof googleEmbedProviderOptionsSchema>;
59
37
  declare const googleImageProviderOptionsSchema: z.ZodObject<{
60
38
  outputGcsUri: z.ZodOptional<z.ZodString>;
@@ -62,8 +40,17 @@ declare const googleImageProviderOptionsSchema: z.ZodObject<{
62
40
  aspectRatio: z.ZodOptional<z.ZodString>;
63
41
  guidanceScale: z.ZodOptional<z.ZodNumber>;
64
42
  seed: z.ZodOptional<z.ZodNumber>;
65
- safetyFilterLevel: z.ZodOptional<z.ZodEnum<["BLOCK_LOW_AND_ABOVE", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_ONLY_HIGH", "BLOCK_NONE"]>>;
66
- personGeneration: z.ZodOptional<z.ZodEnum<["DONT_ALLOW", "ALLOW_ADULT", "ALLOW_ALL"]>>;
43
+ safetyFilterLevel: z.ZodOptional<z.ZodEnum<{
44
+ BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
45
+ BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
46
+ BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
47
+ BLOCK_NONE: "BLOCK_NONE";
48
+ }>>;
49
+ personGeneration: z.ZodOptional<z.ZodEnum<{
50
+ DONT_ALLOW: "DONT_ALLOW";
51
+ ALLOW_ADULT: "ALLOW_ADULT";
52
+ ALLOW_ALL: "ALLOW_ALL";
53
+ }>>;
67
54
  includeSafetyAttributes: z.ZodOptional<z.ZodBoolean>;
68
55
  includeRaiReason: z.ZodOptional<z.ZodBoolean>;
69
56
  language: z.ZodOptional<z.ZodString>;
@@ -73,41 +60,7 @@ declare const googleImageProviderOptionsSchema: z.ZodObject<{
73
60
  labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
74
61
  imageSize: z.ZodOptional<z.ZodString>;
75
62
  enhancePrompt: z.ZodOptional<z.ZodBoolean>;
76
- }, "strict", z.ZodTypeAny, {
77
- seed?: number | undefined;
78
- outputGcsUri?: string | undefined;
79
- negativePrompt?: string | undefined;
80
- aspectRatio?: string | undefined;
81
- guidanceScale?: number | undefined;
82
- safetyFilterLevel?: "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | undefined;
83
- personGeneration?: "DONT_ALLOW" | "ALLOW_ADULT" | "ALLOW_ALL" | undefined;
84
- includeSafetyAttributes?: boolean | undefined;
85
- includeRaiReason?: boolean | undefined;
86
- language?: string | undefined;
87
- outputMimeType?: string | undefined;
88
- outputCompressionQuality?: number | undefined;
89
- addWatermark?: boolean | undefined;
90
- labels?: Record<string, string> | undefined;
91
- imageSize?: string | undefined;
92
- enhancePrompt?: boolean | undefined;
93
- }, {
94
- seed?: number | undefined;
95
- outputGcsUri?: string | undefined;
96
- negativePrompt?: string | undefined;
97
- aspectRatio?: string | undefined;
98
- guidanceScale?: number | undefined;
99
- safetyFilterLevel?: "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | undefined;
100
- personGeneration?: "DONT_ALLOW" | "ALLOW_ADULT" | "ALLOW_ALL" | undefined;
101
- includeSafetyAttributes?: boolean | undefined;
102
- includeRaiReason?: boolean | undefined;
103
- language?: string | undefined;
104
- outputMimeType?: string | undefined;
105
- outputCompressionQuality?: number | undefined;
106
- addWatermark?: boolean | undefined;
107
- labels?: Record<string, string> | undefined;
108
- imageSize?: string | undefined;
109
- enhancePrompt?: boolean | undefined;
110
- }>;
63
+ }, z.core.$strict>;
111
64
  type GoogleImageProviderOptions = z.infer<typeof googleImageProviderOptionsSchema>;
112
65
  declare module '@core-ai/core-ai' {
113
66
  interface GenerateProviderOptions {
@@ -121,24 +74,12 @@ declare module '@core-ai/core-ai' {
121
74
  }
122
75
  }
123
76
  declare const googleProviderOptionsSchema: z.ZodObject<{
124
- stopSequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
77
+ stopSequences: z.ZodOptional<z.ZodArray<z.ZodString>>;
125
78
  frequencyPenalty: z.ZodOptional<z.ZodNumber>;
126
79
  presencePenalty: z.ZodOptional<z.ZodNumber>;
127
80
  seed: z.ZodOptional<z.ZodNumber>;
128
81
  topK: z.ZodOptional<z.ZodNumber>;
129
- }, "strict", z.ZodTypeAny, {
130
- stopSequences?: string[] | undefined;
131
- frequencyPenalty?: number | undefined;
132
- presencePenalty?: number | undefined;
133
- seed?: number | undefined;
134
- topK?: number | undefined;
135
- }, {
136
- stopSequences?: string[] | undefined;
137
- frequencyPenalty?: number | undefined;
138
- presencePenalty?: number | undefined;
139
- seed?: number | undefined;
140
- topK?: number | undefined;
141
- }>;
82
+ }, z.core.$strict>;
142
83
  type GoogleProviderOptions = GoogleGenerateProviderOptions;
143
84
 
144
85
  export { type GoogleEmbedProviderOptions, type GoogleGenAIProvider, type GoogleGenAIProviderOptions, type GoogleGenerateProviderOptions, type GoogleImageProviderOptions, type GoogleProviderOptions as GoogleModelProviderOptions, type GoogleReasoningMetadata, createGoogleGenAI, googleEmbedProviderOptionsSchema, googleGenerateProviderOptionsSchema, googleImageProviderOptionsSchema, googleProviderOptionsSchema };
package/dist/index.js CHANGED
@@ -14,10 +14,12 @@ import {
14
14
  import {
15
15
  FunctionCallingConfigMode
16
16
  } from "@google/genai";
17
- import { zodToJsonSchema } from "zod-to-json-schema";
18
- import { getProviderMetadata } from "@core-ai/core-ai";
17
+ import { getProviderMetadata, zodSchemaToJsonSchema } from "@core-ai/core-ai";
19
18
 
20
19
  // src/model-capabilities.ts
20
+ import {
21
+ stripModelDateSuffix
22
+ } from "@core-ai/core-ai";
21
23
  var DEFAULT_CAPABILITIES = {
22
24
  reasoning: {
23
25
  thinkingParam: "thinkingBudget",
@@ -62,39 +64,36 @@ var MODEL_CAPABILITIES = {
62
64
  }
63
65
  }
64
66
  };
67
+ var GOOGLE_THINKING_LEVEL_MAP = {
68
+ minimal: "LOW",
69
+ low: "LOW",
70
+ medium: "LOW",
71
+ high: "HIGH",
72
+ max: "HIGH"
73
+ };
74
+ var GOOGLE_THINKING_BUDGET_MAP = {
75
+ minimal: 1024,
76
+ low: 4096,
77
+ medium: 16384,
78
+ high: 32768,
79
+ max: 32768
80
+ };
65
81
  function getGoogleModelCapabilities(modelId) {
66
82
  const normalizedModelId = normalizeModelId(modelId);
67
83
  return MODEL_CAPABILITIES[normalizedModelId] ?? DEFAULT_CAPABILITIES;
68
84
  }
69
85
  function normalizeModelId(modelId) {
70
- return modelId.replace(/-\d{8}$/, "");
86
+ return stripModelDateSuffix(modelId);
71
87
  }
72
88
  function toGoogleThinkingLevel(effort) {
73
- if (effort === "high" || effort === "max") {
74
- return "HIGH";
75
- }
76
- return "LOW";
89
+ return GOOGLE_THINKING_LEVEL_MAP[effort];
77
90
  }
78
91
  function toGoogleThinkingBudget(effort) {
79
- if (effort === "minimal") {
80
- return 1024;
81
- }
82
- if (effort === "low") {
83
- return 4096;
84
- }
85
- if (effort === "medium") {
86
- return 16384;
87
- }
88
- return 32768;
92
+ return GOOGLE_THINKING_BUDGET_MAP[effort];
89
93
  }
90
94
 
91
95
  // src/object-utils.ts
92
- function asObject(value) {
93
- if (value && typeof value === "object" && !Array.isArray(value)) {
94
- return value;
95
- }
96
- return {};
97
- }
96
+ import { asObject } from "@core-ai/core-ai";
98
97
 
99
98
  // src/provider-options.ts
100
99
  import { z } from "zod";
@@ -272,8 +271,7 @@ function convertTools(tools) {
272
271
  const functionDeclarations = Object.values(
273
272
  tools
274
273
  ).map((tool) => {
275
- const schema = zodToJsonSchema(tool.parameters);
276
- const { $schema: _schema, ...parametersJsonSchema } = schema;
274
+ const { $schema: _schema, ...parametersJsonSchema } = zodSchemaToJsonSchema(tool.parameters);
277
275
  return {
278
276
  name: tool.name,
279
277
  description: tool.description,
@@ -379,7 +377,7 @@ function createGenerateRequest(modelId, options) {
379
377
  ...options.tools && Object.keys(options.tools).length > 0 ? { tools: convertTools(options.tools) } : {},
380
378
  ...options.toolChoice ? { toolConfig: convertToolChoice(options.toolChoice) } : {},
381
379
  ...mapSamplingToConfig(options),
382
- ...mapReasoningToConfig(modelId, options, googleOptions),
380
+ ...mapReasoningToConfig(modelId, options),
383
381
  ...mapGoogleProviderOptionsToConfig(googleOptions),
384
382
  ...options.signal ? { abortSignal: options.signal } : {}
385
383
  };
@@ -561,7 +559,7 @@ async function* transformStream(stream) {
561
559
  usage
562
560
  };
563
561
  }
564
- function mapReasoningToConfig(modelId, options, _googleProviderOptions) {
562
+ function mapReasoningToConfig(modelId, options) {
565
563
  if (!options.reasoning) {
566
564
  return {};
567
565
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@core-ai/google-genai",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "Google GenAI provider package for @core-ai/core-ai",
5
5
  "license": "MIT",
6
6
  "author": "Omnifact (https://omnifact.ai)",
@@ -43,12 +43,11 @@
43
43
  "test:watch": "vitest"
44
44
  },
45
45
  "dependencies": {
46
- "@core-ai/core-ai": "^0.6.1",
47
- "@google/genai": "^1.42.0",
48
- "zod-to-json-schema": "^3.25.1"
46
+ "@core-ai/core-ai": "^0.7.1",
47
+ "@google/genai": "^1.42.0"
49
48
  },
50
49
  "peerDependencies": {
51
- "zod": "^3.25.0 || ^4.0.0"
50
+ "zod": "^4.0.0"
52
51
  },
53
52
  "devDependencies": {
54
53
  "@core-ai/eslint-config": "*",