Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kits/firestore-genai-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ the CLI connects them to the function at deploy time.
|---|---|---|---|---|
| `provider` | `GENERATIVE_AI_PROVIDER` | no | `google-ai` | `google-ai` or `vertex-ai` |
| `apiKey` | `API_KEY` | secret | — | Google AI API key |
| `model` | `MODEL` | no | `gemini-2.5-flash` | Model id |
| `model` | `MODEL` | no | `gemini-3.6-flash` | Model id |
| `vertexModelLocation` | `VERTEX_AI_MODEL_LOCATION` | no | `null` | Vertex model region |
| `collectionName` | `COLLECTION_NAME` | no | `generate` | Discussion collection |
| `promptField` | `PROMPT_FIELD` | no | `prompt` | Prompt field name |
Expand Down
2 changes: 1 addition & 1 deletion kits/firestore-genai-chatbot/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const params = {
input: select([...GENERATIVE_AI_PROVIDER_OPTIONS]),
}),
apiKey: defineSecret("API_KEY"),
model: defineString("MODEL", { default: "gemini-2.5-flash" }),
model: defineString("MODEL", { default: "gemini-3.6-flash" }),
vertexModelLocation: defineString("VERTEX_AI_MODEL_LOCATION", {
default: "null",
input: select([...VERTEX_MODEL_LOCATION_OPTIONS]),
Expand Down
2 changes: 1 addition & 1 deletion kits/firestore-genai-chatbot/src/export-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface GenaiChatbotConfig {
provider?: GenerativeAIProvider | "google-ai" | "vertex-ai";
/** API key for the `google-ai` provider. */
apiKey?: string;
/** Model id, e.g. `gemini-2.5-flash`. */
/** Model id, e.g. `gemini-3.6-flash`. */
model: string;
/** Vertex AI model location. */
vertexModelLocation?: string;
Expand Down
58 changes: 25 additions & 33 deletions kits/firestore-genai-chatbot/src/generative-client/genkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,41 +103,33 @@ export class GenkitDiscussionClient extends DiscussionClient<
return genkit(genkitConfig);
}

// TODO(migration): inherited verbatim from the legacy extension — this
// hardcoded model allowlist means new/custom/fine-tuned models need a package
// update. `googleAI.model()` / `vertexAI.model()` resolve any id dynamically;
// consider simplifying to that. Improvement, not a bug. Deferred from PR #431 review.
/**
* Resolves a Genkit model reference for the configured provider.
*
* Known ids are registered first so version aliases still match. Unknown
* ids fall through to `googleAI.model()` / `vertexAI.model()` so current
* Gemini releases work without a package update.
*/
static createModelReference(
model: string,
provider: string
): ModelReference<any> {
const modelReferences =
provider === "google-ai"
? [
googleAI.model("gemini-1.5-flash"),
googleAI.model("gemini-1.5-pro"),
googleAI.model("gemini-2.0-flash"),
googleAI.model("gemini-2.0-flash-lite"),
googleAI.model("gemini-2.5-flash-lite"),
googleAI.model("gemini-2.5-flash"),
googleAI.model("gemini-2.5-pro"),
googleAI.model("gemini-3-pro-preview"),
googleAI.model("gemini-3-pro-image-preview"),
]
: [
vertexAI.model("gemini-1.5-flash"),
vertexAI.model("gemini-1.5-pro"),
vertexAI.model("gemini-2.0-flash"),
vertexAI.model("gemini-2.0-flash-lite"),
vertexAI.model("gemini-2.0-flash-001"),
vertexAI.model("gemini-2.5-flash-lite"),
vertexAI.model("gemini-2.5-flash"),
vertexAI.model("gemini-2.5-pro"),
vertexAI.model("gemini-3-pro-preview"),
vertexAI.model("gemini-3-pro-image-preview"),
];

const pluginName = provider === "google-ai" ? "googleai" : "vertexai";
const isGoogleAi = provider === "google-ai";
const pluginName = isGoogleAi ? "googleai" : "vertexai";
const knownIds = [
"gemini-3.6-flash",
"gemini-3.5-flash",
"gemini-3.5-flash-lite",
"gemini-3.1-flash-lite",
"gemini-3.1-pro-preview",
"gemini-2.5-flash-lite",
"gemini-2.5-flash",
"gemini-2.5-pro",
] as const;

const modelReferences = knownIds.map((id) =>
isGoogleAi ? googleAI.model(id) : vertexAI.model(id)
);

for (const modelReference of modelReferences) {
if (modelReference.name === `${pluginName}/${model}`) {
Expand All @@ -147,7 +139,7 @@ export class GenkitDiscussionClient extends DiscussionClient<
return modelReference.withVersion(model);
}
}
throw new Error("Model not found.");
return isGoogleAi ? googleAI.model(model) : vertexAI.model(model);
}

private createGenerateOptions(
Expand All @@ -172,7 +164,7 @@ export class GenkitDiscussionClient extends DiscussionClient<
};
}

/** Whether the Genkit client can serve this config (single candidate + known model). */
/** Whether the Genkit client can serve this config (single candidate). */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since createModelReference has been updated to never throw and always return a ModelReference (falling back to dynamic resolution), the check !!GenkitDiscussionClient.createModelReference(...) in shouldUseGenkitClient will always evaluate to true.

We can simplify shouldUseGenkitClient to only check the candidate count, avoiding redundant model reference creation:

  static shouldUseGenkitClient(config: ResolvedGenaiChatbotConfig): boolean {
    const shouldReturnMultipleCandidates =
      config.candidateCount && config.candidateCount > 1;
    return !shouldReturnMultipleCandidates;
  }

static shouldUseGenkitClient(config: ResolvedGenaiChatbotConfig): boolean {
const shouldReturnMultipleCandidates =
config.candidateCount && config.candidateCount > 1;
Expand Down
15 changes: 15 additions & 0 deletions kits/firestore-genai-chatbot/tests/generative-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ describe("GenkitDiscussionClient.shouldUseGenkitClient", () => {
const config = resolveConfig({ ...baseInput, candidateCount: 2 });
expect(GenkitDiscussionClient.shouldUseGenkitClient(config)).toBe(false);
});

test("true for a current model id that is not in the legacy allowlist", () => {
const config = resolveConfig({
...baseInput,
model: "gemini-3.6-flash",
candidateCount: 1,
});
expect(GenkitDiscussionClient.shouldUseGenkitClient(config)).toBe(true);
expect(() =>
GenkitDiscussionClient.createModelReference(
"gemini-3.6-flash",
"google-ai"
)
).not.toThrow();
});
});

describe("VertexDiscussionClient", () => {
Expand Down
2 changes: 1 addition & 1 deletion kits/firestore-translate-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ the CLI connects them to the function at deploy time.
| `languages` | `LANGUAGES` | no | `en,es,de,fr` | Target language codes |
| `languagesFieldName` | `LANGUAGES_FIELD_NAME` | no | `languages` | Per-doc languages field |
| `provider` | `TRANSLATION_PROVIDER` | yes | — | Translation provider |
| `geminiModel` | `GEMINI_MODEL` | no | `gemini-2.5-flash` | Gemini model when used |
| `geminiModel` | `GEMINI_MODEL` | no | `gemini-3.6-flash` | Gemini model when used |
| `googleAiApiKey` | `GOOGLE_AI_API_KEY` | secret | — | Google AI API key (Gemini) |

## Multiple instances
Expand Down
7 changes: 6 additions & 1 deletion kits/firestore-translate-text/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const TRANSLATION_PROVIDER_OPTIONS = [
"gemini-vertexai",
] as const;
const GEMINI_MODEL_OPTIONS = [
"gemini-3.1-pro-preview",
"gemini-3.6-flash",
"gemini-3.5-flash",
"gemini-3.5-flash-lite",
"gemini-3.1-flash-lite",
Comment on lines +40 to +44

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The GEMINI_MODEL_OPTIONS list is missing gemini-3.5-flash and gemini-3.5-flash-lite, which are valid Gemini 3.x models and are included in the chatbot's knownIds. Adding them here ensures consistency across extensions and allows users to select these models from the dropdown in the Firebase Console.

Suggested change
"gemini-3.1-pro-preview",
"gemini-3.6-flash",
"gemini-3.1-flash-lite",
"gemini-3.6-flash",
"gemini-3.5-flash",
"gemini-3.5-flash-lite",
"gemini-3.1-flash-lite",
"gemini-3.1-pro-preview",

"gemini-2.5-pro",
"gemini-2.5-flash",
"gemini-2.5-flash-lite",
Expand All @@ -54,7 +59,7 @@ const params = {
input: select([...TRANSLATION_PROVIDER_OPTIONS]),
}),
geminiModel: defineString("GEMINI_MODEL", {
default: "gemini-2.5-flash",
default: "gemini-3.6-flash",
input: select([...GEMINI_MODEL_OPTIONS]),
}),
};
Expand Down
2 changes: 1 addition & 1 deletion kits/firestore-translate-text/src/export-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ResolvedTranslateConfig {
}

const DEFAULT_PROVIDER: TranslationProvider = "translate";
const DEFAULT_GEMINI_MODEL = "gemini-2.5-flash";
const DEFAULT_GEMINI_MODEL = "gemini-3.6-flash";

function toUniqueArray(
languages: ReadonlyArray<string> | string
Expand Down
6 changes: 4 additions & 2 deletions kits/firestore-vector-search/src/embeddings/client/genkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { type EmbedderReference, type Genkit, genkit } from "genkit";
import type { ResolvedVectorSearchConfig } from "../../export-config";
import { BaseEmbedClient } from "./base_class";

const GEMINI_EMBEDDER_ID = "gemini-embedding-2";

export class GenkitEmbedClient extends BaseEmbedClient {
private readonly client: Genkit;
private readonly embedder: EmbedderReference;
Expand All @@ -29,10 +31,10 @@ export class GenkitEmbedClient extends BaseEmbedClient {
this.dimension = config.dimension;
const isVertex = config.embeddingProvider === "vertex";
this.embedder = isVertex
? vertexAI.embedder("gemini-embedding-001", {
? vertexAI.embedder(GEMINI_EMBEDDER_ID, {
outputDimensionality: config.dimension,
})
: googleAI.embedder("gemini-embedding-001", {
: googleAI.embedder(GEMINI_EMBEDDER_ID, {
outputDimensionality: config.dimension,
});
this.client = genkit({
Expand Down
6 changes: 4 additions & 2 deletions kits/storage-resize-images/src/content-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const HARM_CATEGORIES = [
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
"HARM_CATEGORY_HARASSMENT",
] as const;
/** Similar price to previous `gemini-2.5-flash`, better quality than 2.5 Flash. Higher Flash/Lite tiers cost more. */
const CONTENT_FILTER_MODEL = "gemini-3.1-flash-lite";
const RETRY_BASE_MS = 500;
const RETRY_JITTER_MS = 200;
const RETRY_MAX_MS = 5000;
Expand Down Expand Up @@ -88,7 +90,7 @@ export async function checkImageContent(
plugins: [
vertexAI({
location,
models: ["gemini-2.5-flash"],
models: [CONTENT_FILTER_MODEL],
}),
],
});
Expand All @@ -112,7 +114,7 @@ export async function checkImageContent(

try {
const result = await ai.generate({
model: gemini("gemini-2.5-flash"),
model: gemini(CONTENT_FILTER_MODEL),
messages: [
{
role: "user",
Expand Down
Loading