Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Gemini Text Processor

Command-line Python tool for batch analysis, rewriting, summarisation and translation of Markdown and plain-text files using the Gemini API.

The tool accepts a single .txt or .md file, or a folder containing multiple files. It processes each supported file and saves the result to a chosen output directory.

Features

  • Processes individual files or folders recursively
  • Supports .txt and .md input files
  • Supports five tasks:
    • analyze
    • rewrite
    • summarize
    • translate
    • custom
  • Produces output in Romanian, English or Hungarian
  • Saves one output file per input file
  • Preserves Markdown formatting when appropriate
  • Supports custom prompts for specialised document transformations
  • Allows model, temperature and maximum-output-token configuration
  • Supports inline text processing or optional Gemini Files API uploads
  • Uses environment variables for API-key handling
  • Continues processing remaining files if an individual file fails

Technologies

  • Python 3.10+
  • Google Gen AI SDK
  • Gemini API
  • Gemini Files API
  • argparse
  • Batch file processing
  • Prompt engineering

Requirements

Install the dependency:

pip install google-genai

Or create a requirements.txt file containing:

google-genai

Then install it with:

pip install -r requirements.txt

API Key Setup

Set one of the following environment variables before running the tool.

PowerShell:

$env:GEMINI_API_KEY="your_api_key"

Alternatively:

$env:GOOGLE_API_KEY="your_api_key"

Never add API keys directly to the script or commit them to GitHub.

Basic Usage

The general command format is:

python gemini_text_processor.py INPUT_PATH --task TASK --output-language LANGUAGE

Available tasks:

analyze
rewrite
summarize
translate
custom

Available output languages:

romanian
english
hungarian

Examples

Analyse one text file and save a Romanian report:

python gemini_text_processor.py "input\document.txt" `
  --task analyze `
  --output-language romanian

Summarise all supported files in a folder in English:

python gemini_text_processor.py "input" `
  --task summarize `
  --output-language english `
  --output-dir "output"

Translate a Markdown file into Hungarian:

python gemini_text_processor.py "input\document.md" `
  --task translate `
  --output-language hungarian

Rewrite documents for clarity and save them with a custom filename suffix:

python gemini_text_processor.py "input" `
  --task rewrite `
  --output-language english `
  --suffix improved-en

Use a custom transformation prompt:

python gemini_text_processor.py "input\document.txt" `
  --task custom `
  --output-language english `
  --custom-prompt "Extract the main decisions, deadlines and action items. Return a concise Markdown report."

Process files through Gemini Files API instead of placing their content directly in the prompt:

python gemini_text_processor.py "input" `
  --task summarize `
  --output-language english `
  --use-files-api

Output Naming

By default, output files retain the original extension and receive a suffix based on the selected task and output language.

Example:

meeting-notes.txt
meeting-notes.summarize-english.txt

A custom suffix can be set with --suffix.

Configuration Options

--output-dir            Output directory, default: output
--model                 Gemini model, default: gemini-2.5-flash
--temperature           Generation temperature, default: 0.3
--max-output-tokens     Maximum output tokens, default: 4000
--use-files-api         Upload files through Gemini Files API
--suffix                Custom output-file suffix
--custom-prompt         Required when using --task custom

Privacy and Data Handling

This repository does not include sample documents, generated outputs or API keys.

When the tool is used, document content is sent to the Gemini API either as inline text or through the Gemini Files API when --use-files-api is selected. Review the applicable API terms and data-handling requirements before processing confidential, personal or sensitive documents.

Portfolio Context

This project demonstrates practical AI-assisted document processing with a reusable command-line interface, multilingual output control, batch-folder processing, configurable prompts, error handling and structured file output.

About

Command-line Python tool for batch analysis, rewriting, summarisation and translation of text files using the Gemini API.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages