gemini-batch
Version:
Batch processing for Google Gemini AI
133 lines (130 loc) • 5.27 kB
JavaScript
import { config, handleConfigList, handleConfigSetKey, handleConfigSetModel, handleFileCreate, handleFileGet, handleFileList, handleJobCancel, handleJobDownload, handleJobGet, handleJobList, handleJobSubmit, logger } from "./job-DUt-ctiL.js";
import "dotenv/config";
import path from "node:path";
import { Command } from "commander";
//#region package.json
var name = "gemini-batch";
var version = "1.0.14";
var description = "Batch processing for Google Gemini AI";
var type = "module";
var files = ["dist", "bin"];
var main = "./dist/index.js";
var module = "./dist/index.js";
var types = "./dist/index.d.ts";
var exports = {
".": "./dist/index.js",
"./package.json": "./package.json"
};
var bin = { "gemini-batch": "./bin/gemini-batch" };
var scripts = {
"build": "tsdown",
"dev": "tsdown --watch",
"release": "./scripts/publish.sh"
};
var dependencies = {
"@google/genai": "1.15.0",
"chalk": "5.6.0",
"cli-table3": "0.6.5",
"commander": "14.0.0",
"dotenv": "17.2.1",
"glob": "11.0.3",
"ora": "8.2.0",
"pretty-bytes": "7.0.1",
"zod": "4.1.1"
};
var devDependencies = {
"@types/node": "24.3.0",
"tsdown": "0.14.1",
"typescript": "5.9.2"
};
var keywords = ["gemini", "batch"];
var author = "zoubingwu@gmail.com";
var license = "MIT";
var bugs = { "url": "https://github.com/zoubingwu/gemini-batch/issues" };
var homepage = "https://github.com/zoubingwu/gemini-batch#readme";
var repository = {
"type": "git",
"url": "git+https://github.com/zoubingwu/gemini-batch.git"
};
var package_default = {
name,
version,
description,
type,
files,
main,
module,
types,
exports,
bin,
scripts,
dependencies,
devDependencies,
keywords,
author,
license,
bugs,
homepage,
repository
};
//#endregion
//#region src/cli.ts
const program = new Command();
program.name("gemini-batch").description("Batch processing for Google Gemini AI").version(package_default.version);
const configCommand = program.command("config").description("Configuration management");
configCommand.command("list").description("List current configuration").action(async () => {
await handleConfigList();
});
configCommand.command("set-key").description("Set Gemini API key").argument("<apiKey>", "Your gemini API key").action(async (apiKey) => {
await handleConfigSetKey(apiKey);
});
configCommand.command("set-model").description("Set default model").argument("<model>", "Your default gemini model").action(async (model) => {
await handleConfigSetModel(model);
});
const jobCommand = program.command("job").description("Job management");
jobCommand.command("list").description("List jobs").option("-n, --limit <num>", "Number of jobs to display", "20").action(async (options) => {
await handleJobList({ limit: parseInt(options.limit) });
});
jobCommand.command("submit").description("Submit batch processing job").argument("[input]", "Path to input JSONL file or existing file ID (starts with 'files/')").option("--json", "Output in JSON format").action(async (input, options) => {
if (options.json) logger.setSilent(true);
const result = await handleJobSubmit(input, options);
if (!result) process.exit(1);
});
jobCommand.command("cancel").description("Cancel job").argument("<jobId>", "ID of the job to cancel").action(async (jobId) => {
const result = await handleJobCancel(jobId);
if (!result) process.exit(1);
});
jobCommand.command("get").description("Get job details").argument("<jobId>", "ID of the job to get").option("--json", "Output in JSON format").action(async (jobId, options) => {
if (options.json) logger.setSilent(true);
const result = await handleJobGet(jobId, options);
if (!result) process.exit(1);
});
jobCommand.command("download").description("Download job result").argument("<jobId>", "ID of the job to download results for").option("-o, --output <dir>", "Output directory for results").option("--json", "Output in JSON format").action(async (jobId, options) => {
if (options.json) logger.setSilent(true);
await config.load();
const result = await handleJobDownload(jobId, {
output: options.output ?? path.resolve(config.configDir, "results"),
json: options.json
});
if (!result) process.exit(1);
});
const fileCommand = program.command("file").description("File management");
fileCommand.command("list").description("List files").option("-n, --limit <num>", "Number of files to display", "10").action(async (options) => {
await handleFileList({ limit: parseInt(options.limit) });
});
fileCommand.command("get").description("Get file details").argument("<fileName>", "Name or display name of the file").action(async (fileName) => {
const result = await handleFileGet(fileName);
if (!result) process.exit(1);
});
fileCommand.command("create").description("Create a new jsonl file for batch processing").requiredOption("-p, --prompt <prompt_or_path>", "Prompt text or path to prompt file").requiredOption("-i, --input <input>", "File glob pattern (e.g., './input/*.md') or JSON array field (e.g., 'data.json:items')").requiredOption("-o, --output <path>", "Output JSONL file path").action(async (options) => {
await config.load();
const result = await handleFileCreate({
...options,
model: config.getModel()
});
if (!result) process.exit(1);
});
program.parse();
//#endregion
export { };
//# sourceMappingURL=cli.js.map