File size: 1,401 Bytes
85db553 2436ec9 85db553 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
---
sdk: gradio
---
# LLM LSP
A proof of concept for intelligent document editing that works like humans do - scan, jump, edit.
## The Idea
Instead of making AI read entire documents, we let it:
1. Scan headers to find location (like grep)
2. Jump to right section (like sed)
3. Make targeted changes
4. Put it back (like cat)
## Quick Start
```python
pip install -r requirements.txt # openai, gradio
from lsp import LSP
editor = LSP(api_key="your-key")
editor.edit("doc.md", "add version warning")
```
## How It Works
1. **Map Sections Fast**
```python
sections = find_sections("doc.md") # Uses grep-like scan
```
2. **AI Picks Target**
```json
{
"sections": {"## Setup": 10, "## Config": 50},
"task": "add version warning",
"target": "## Setup at line 10"
}
```
3. **Extract & Edit**
```python
content = extract_section(file, 10, 49) # Just that piece
new_content = ai.modify(content) # AI edits small part
```
4. **Put It Back**
```python
replace_section(file, 10, 49, new_content)
```
## Try It
```bash
python main.py # Launches Gradio UI
```
## Status
- POC stage
- Works with markdown files
- Uses gpt-4o-mini
- Basic UI
## Limits
- One section at a time
- Just markdown for now
- No fancy error handling
- Will fuck up if sections aren't clear
## Next Steps?
- Handle multiple sections
- Better section detection
- More formats
- Whatever you need it to do |