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

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.4.tar.gz (10.1 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.4-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_editor-0.1.4.tar.gz
  • Upload date:
  • Size: 10.1 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.4.tar.gz
Algorithm Hash digest
SHA256 755d3774b6734641b9ceac04e2b7f899f61b8f5d9cccc48d428254b24825799f
MD5 6c07821b956fd26576f79b3eed7b4676
BLAKE2b-256 b6d188af21a435072830c0a266705c38c47658652a6aa17076a73c4337a339c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llm_editor-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.2 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4f168645589f36908c965382fd0942f3819fc98f8644be46caf4990d66a35fe2
MD5 777f01c10068a40c14c61d1e5366aa40
BLAKE2b-256 06af219a42bd2b99e1599350147ace361ac24d94f41caabb64812443c41d6a66

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