static createModelReference()

in firestore-genai-chatbot/functions/src/generative-client/genkit.ts [86:121]


  static createModelReference(
    model: string,
    provider: string
  ): ModelReference<any> {
    const modelReferences =
      provider === 'google-ai'
        ? [
            gemini10ProGoogleAI,
            gemini15FlashGoogleAI,
            gemini15ProGoogleAI,
            gemini20FlashGoogleAI,
            gemini20FlashLiteGoogleAI,
            gemini20ProExp0205GoogleAI,
          ]
        : [
            gemini10ProVertexAI,
            gemini15FlashVertexAI,
            gemini15ProVertexAI,
            gemini20FlashVertexAI,
            gemini20FlashLiteVertexAI,
            gemini20ProExp0205VertexAI,
            gemini20FlashLitePreview0205VertexAI,
          ];

    const pluginName = provider === 'google-ai' ? 'googleai' : 'vertexai';

    for (const modelReference of modelReferences) {
      if (modelReference.name === `${pluginName}/${model}`) {
        return modelReference;
      }
      if (modelReference.info?.versions?.includes(model)) {
        return modelReference.withVersion(model);
      }
    }
    throw new Error('Model not found.');
  }