in firestore-palm-summarize-text/functions/src/generator.ts [58:97]
constructor(options: TextGeneratorOptions = {}) {
this.temperature = options.temperature;
this.topP = options.topP;
this.topK = options.topK;
this.maxOutputTokens = options.maxOutputTokens || 1024;
this.candidateCount = options.candidateCount;
this.instruction = options.instruction;
this.generativeSafetySettings = options.generativeSafetySettings || [];
if (options.model) this.model = options.model;
this.endpoint = `projects/${config.projectId}/locations/${config.location}/publishers/google/models/${this.model}`;
if (config.provider === 'vertex') {
// here location is hard-coded, following https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings#generative-ai-get-text-embedding-nodejs
const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};
this.vertexClient = new v1.PredictionServiceClient(clientOptions);
} else {
if (config.apiKey) {
logs.usingAPIKey();
const authClient = new GoogleAuth().fromAPIKey(config.apiKey);
this.generativeClient = new TextServiceClient({
authClient,
});
} else {
logs.usingADC();
const auth = new GoogleAuth({
scopes: [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/generative-language',
],
});
this.generativeClient = new TextServiceClient({
auth,
});
}
}
}