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
6 changes: 4 additions & 2 deletions library/runner-cli/advanced_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ async function main(): Promise<void> {
"-a, --additionalContext <context>",
"A short description of the conversation to add context."
)
.option("-v, --vertexProject <project>", "The Vertex Project name.");
.option("-v, --vertexProject <project>", "The Vertex Project name.")
.option("-k, --keyFilename <file>", "Path to the service account key file for authentication.");
program.parse(process.argv);
const options = program.opts();

Expand Down Expand Up @@ -187,7 +188,8 @@ async function main(): Promise<void> {
options.vertexProject,
comments,
undefined,
options.additionalContext
options.additionalContext,
options.keyFilename
);
writeFileSync(options.outputBasename + "-summary.json", JSON.stringify(summary, null, 2));
}
Expand Down
5 changes: 3 additions & 2 deletions library/runner-cli/categorization_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ async function main(): Promise<void> {
.option(
"-f, --forceRerun",
"Force rerun of categorization, ignoring existing topics in the input file."
);
)
.option("-k, --keyFilename <file>", "Path to the service account key file for authentication.");
program.parse(process.argv);
const options = program.opts();
options.topicDepth = parseInt(options.topicDepth);
Expand All @@ -80,7 +81,7 @@ async function main(): Promise<void> {

// Learn topics and categorize comments.
const sensemaker = new Sensemaker({
defaultModel: new VertexModel(options.vertexProject, "global"),
defaultModel: new VertexModel(options.vertexProject, "global", "gemini-2.5-flash-lite", options.keyFilename),
});
const topics = options.topics ? getTopics(options.topics) : undefined;
const categorizedComments = await sensemaker.categorizeComments(
Expand Down
6 changes: 4 additions & 2 deletions library/runner-cli/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ async function main(): Promise<void> {
"-a, --additionalContext <context>",
"A short description of the conversation to add context."
)
.option("-v, --vertexProject <project>", "The Vertex Project name.");
.option("-v, --vertexProject <project>", "The Vertex Project name.")
.option("-k, --keyFilename <file>", "Path to the service account key file for authentication.");
program.parse(process.argv);
const options = program.opts();

Expand All @@ -63,7 +64,8 @@ async function main(): Promise<void> {
options.vertexProject,
comments,
undefined,
options.additionalContext
options.additionalContext,
options.keyFilename
);

const markdownContent = summary.getText("MARKDOWN");
Expand Down
10 changes: 6 additions & 4 deletions library/runner-cli/runner_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ export function writeSummaryToGroundedCSV(summary: Summary, outputFilePath: stri
*/
export async function getTopicsAndSubtopics(
project: string,
comments: Comment[]
comments: Comment[],
keyFilename?: string
): Promise<Topic[]> {
const sensemaker = new Sensemaker({
defaultModel: new VertexModel(project, "global"),
defaultModel: new VertexModel(project, "global", "gemini-2.5-pro-preview-06-05", keyFilename),
});
return await sensemaker.learnTopics(comments, true);
}
Expand All @@ -150,10 +151,11 @@ export async function getSummary(
project: string,
comments: Comment[],
topics?: Topic[],
additionalContext?: string
additionalContext?: string,
keyFilename?: string
): Promise<Summary> {
const sensemaker = new Sensemaker({
defaultModel: new VertexModel(project, "global"),
defaultModel: new VertexModel(project, "global", "gemini-2.5-pro-preview-06-05", keyFilename),
});
// TODO: Make the summariation type an argument and add it as a flag in runner.ts. The data
// requirements (like requiring votes) would also need updated.
Expand Down
24 changes: 21 additions & 3 deletions library/src/models/vertex_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export class VertexModel extends Model {
constructor(
project: string,
location: string,
modelName: string = "gemini-2.5-pro-preview-06-05"
modelName: string = "gemini-2.5-pro-preview-06-05",
keyFilename?: string
) {
super();
if (modelName === "gemini-2.5-pro-preview-06-05" && location != "global") {
Expand All @@ -58,11 +59,28 @@ export class VertexModel extends Model {
"https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-pro for more information."
);
}
this.vertexAI = new VertexAI({

const vertexOptions: {
project: string;
location: string;
apiEndpoint: string;
googleAuthOptions?: {
keyFilename?: string;
};
} = {
project: project,
location: location,
apiEndpoint: "aiplatform.googleapis.com",
});
};

if (keyFilename) {
vertexOptions.googleAuthOptions = {
keyFilename: keyFilename
};
console.log(`Using service account key from: ${keyFilename}`);
}

this.vertexAI = new VertexAI(vertexOptions);
this.modelName = modelName;

console.log("Creating VertexModel with ", DEFAULT_VERTEX_PARALLELISM, " parallel workers...");
Expand Down
Loading