Skip to main content

A CLI tool to edit and chat with files using LLMs

Project description

LLM Editor

A CLI tool to edit files using LLMs.

Installation

pip install llm-editor

or, if you are installing from git directly

git@github.com:gptabhinav/llm-editor.git
pip install .

Configuration

You can configure the tool using a YAML file.

YAML Configuration

Run the following command to generate a default configuration file at ~/.llm-editor/config.yaml:

edit --init-config

Then edit the file to add your API key:

llm:
  provider: openai
  api_key: "your-api-key"
  model: "gpt-4o"

app:
  backup_enabled: true
  backup_suffix: ".backup"

Usage

1. Using Prompt Tags (Scripting Mode)

Add your instructions directly to the file using <tag> markers.

Example input.txt:

<tag> start_prompt
Convert the following Python code to JavaScript.
<tag> end_prompt

def greet(name):
    print(f"Hello, {name}!")

greet("World")

Run the tool:

edit input.txt

2. Interactive Mode

If the input file does not contain prompt tags, the tool will open your default text editor (configured via $EDITOR). You can type your instructions there, save, and close the editor to proceed.

Interactive Mode Workflow

3. Chat Mode

You can start an interactive chat session about your files using the --chat flag. This is useful for asking questions, getting explanations, or discussing potential changes without modifying the files directly.

Single File:

edit file.py --chat

Multiple Files: You can pass multiple files to load them all into the chat context.

edit file1.py file2.py --chat

Directories & Patterns: You can also pass directories or glob patterns to load multiple files at once.

# Load all files in a directory (recursive)
edit src/ --chat

# Load all Python files using glob pattern
# (Use quotes to ensure the tool handles the pattern matching)
edit "src/**/*.py" --chat

Options

  • --outfile <path>: Write output to a specific file (input file is preserved).
  • --inplace: Overwrite the input file directly (skips backup).
  • --init-config: Initialize the configuration file.
  • --chat: Start an interactive chat session about the file(s).

Usage Tracking & Costs

The tool automatically tracks token usage and estimates costs for each operation.

Logs are stored in ~/.llm-editor/logs/usage.log and contain:

  • Timestamp
  • Model used
  • Token counts (Input/Output/Total)
  • Estimated cost (USD)

Example log entry:

--- Usage Report (2023-10-27T10:00:00.123456) ---
Model: gpt-4o
Input Tokens:  150
Output Tokens: 50
Total Tokens:  200
Estimated Cost: $0.001250
------------------------------

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_editor-0.1.5.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_editor-0.1.5-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file llm_editor-0.1.5.tar.gz.

File metadata

  • Download URL: llm_editor-0.1.5.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llm_editor-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9caf18792514cc3b99759955103f480de4a6e50a863d65046f702b8fb07663f3
MD5 6361b3cc884d9058e070ceab915baf95
BLAKE2b-256 748bcf507cb183a4bfee63d7d467efb6477a4eb9dcf22a65d36a283bdcb84453

See more details on using hashes here.

File details

Details for the file llm_editor-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: llm_editor-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llm_editor-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 23f0347d1c9c6fd162c09bbe3b73cee422269feab5c7307d202699bf1b848274
MD5 6b488d5a501072e3a6089fffdb0b1509
BLAKE2b-256 439432269cb2de4c018447dc47616fd120e8e9ff904872071e843b6c51ede6fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page