Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
GitOrigin-RevId: f04d8d901cd2050a7825acf8f5571f6f2cf0344f
  • Loading branch information
Jigsaw authored and copybara-github committed Jan 22, 2025
1 parent 907f51e commit eb7bf35
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions runner-cli/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import { Command } from "commander";
import * as fs from "fs";
import { marked } from "marked";
import { getCommentsFromCsv, getSummary, getTopicsFromComments } from "./runner_utils";
import {
getCommentsFromCsv,
getSummary,
getTopicsFromComments,
getTopicsAndSubtopics,
} from "./runner_utils";
import { type Topic } from "../src/types";

async function main(): Promise<void> {
// Parse command line arguments.
Expand All @@ -30,7 +36,15 @@ async function main(): Promise<void> {
const options = program.opts();

const comments = await getCommentsFromCsv(options.inputFile);
const topics = getTopicsFromComments(comments);
// check if any comments have topics before using getTopicsFromComments, otherwise, learn topics using runner_utils function
let topics: Topic[];
if (comments.length > 0 && comments.some((comment) => comment.topics)) {
console.log("Comments already have topics. Skipping topic learning.");
topics = getTopicsFromComments(comments);
} else {
console.log("Learning topics from comments.");
topics = await getTopicsAndSubtopics(options.vertexProject, comments);
}

const summary = await getSummary(options.vertexProject, comments, topics);
const markdownContent = summary.getText("MARKDOWN");
Expand Down

0 comments on commit eb7bf35

Please sign in to comment.