Metadata-Version: 2.1
Name: llmatex
Version: 0.1.0
Summary: CLI program for converting natural language text to LaTeX
Author: trungle15
Requires-Python: >=3.9,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: local
Requires-Dist: groq (>=0.9.0,<0.10.0)
Requires-Dist: llama_cpp_python (>=0.2.82,<0.3.0) ; extra == "local"
Requires-Dist: matplotlib (>=3.9.1,<4.0.0)
Requires-Dist: pynput (>=1.7.7,<2.0.0)
Requires-Dist: pyperclip (>=1.9.0,<2.0.0)
Requires-Dist: rich (>=13.7.0,<14.0.0)
Requires-Dist: sympy (>=1.13.1,<2.0.0)
Requires-Dist: torch (>=2.3.1,<3.0.0) ; extra == "local"
Requires-Dist: transformers (>=4.42.3,<5.0.0) ; extra == "local"
Description-Content-Type: text/markdown

# llamatex

Convert natural language descriptions to LaTeX equations in your terminal, in under a second!

## Features

`llamatex` offers two primary modes of operation:
1. Single Instruction Mode: Generate LaTeX for a single equation description.
2. Clipboard Mode: Send LaTeX code from highlighted text into your clipboard.
3. Markdown File Editing Mode: Automatically replace natural language descriptions with LaTeX equations in a markdown file.

For equations that can be rendered in a single line, smoltex opens a new window displaying the rendered equation.

## Installation

```bash
pip install llamatex
```

For local generation support:

```bash
pip install llamatex[local]
```

Alternatively, you can build from source using `poetry`.

```bash
poetry install
```

## Usage

### Single Instruction mode

```bash
llamatex render -p "equation for the area of a circle"
```

Output:

```
Latex string: A = \pi r^2

>> completion time: 856.4 ms
```

### Clipboard mode

> [!WARNING]
> `llamatex` clipboard mode currently only supports MacOS

`llamatex` uses `pynput` to listen to your inputs and control the keyboard. To allow clipboard mode, allow your terminal/IDE to be added to Assessibility in System Settings.

Run `llamatex` in clipboard mode using the following command:

```bash
llamatex run
```

### Markdown File Editing Mode
1. Create a markdown file (e.g., `equations.md`) with placeholders:

```markdown
# Important Equations

1. Area of a circle:
{"area of a circle"}

2. Einstein's mass-energy equivalence:
{"einstein's famous equation"}
```
2. Run `llmatex`:

```bash
llamatex render -f equations.md
```

3. The file will be updated with LaTeX equations:

```markdown
# Important Equations

1. Area of a circle:
$A = \pi r^2$

2. Einstein's mass-energy equivalence:
$E = mc^2$
```

Use the hotkey `Cmd+Shift+L` (on macOS) to process the selected text. Press `esc` to exit the program.

## Configuration

### API Setup

1. Get a free API key from Groq console.
2. Set the environment variable

```bash
export GROQ_API_KEY=your-api-key-here
```

Available models:
- llama3: `llama3-8b`, `llama3-70b`, `llama3.1-8b`, `llama3.1-70b`
- gemma: `gemma-7b`, `gemma2-9b`
- mixtral: `mixtral-8x7b`
- Phi3 (local only): `phi-3-mini`

### Server selection
Choose between `groq` (default) or `llama-cpp` (for local generation) using the `-s` or `--server` option:

```bash
llamatex render -p "pythagorean theorem" -s llama-cpp
```








