210 lines
4.9 KiB
Markdown
210 lines
4.9 KiB
Markdown
# llms.txt Generator
|
||
|
||
Generate [llms.txt](https://llmstxt.org/) documentation for GitHub repositories using DSPy.
|
||
|
||
## What is llms.txt?
|
||
|
||
`llms.txt` is a proposed standard for providing structured, LLM-friendly documentation about a project. It typically includes:
|
||
|
||
- Project overview and purpose
|
||
- Key concepts and terminology
|
||
- Architecture and structure
|
||
- Usage examples
|
||
- Important files and directories
|
||
|
||
This tool uses DSPy (Declarative Self-improving Python) to automatically analyze GitHub repositories and generate comprehensive `llms.txt` documentation.
|
||
|
||
## Installation
|
||
|
||
This project uses `uv` for dependency management. If you don't have it installed:
|
||
|
||
```bash
|
||
# Install uv
|
||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||
```
|
||
|
||
Then install the project dependencies:
|
||
|
||
```bash
|
||
uv sync
|
||
```
|
||
|
||
## Configuration
|
||
|
||
You'll need two API keys:
|
||
|
||
1. **OpenAI API Key** - Required for DSPy to use language models
|
||
2. **GitHub Access Token** - Optional but recommended for higher rate limits
|
||
|
||
### Option 1: Using .env file (Recommended)
|
||
|
||
Create a `.env` file in the project root:
|
||
|
||
```bash
|
||
cp .env.example .env
|
||
```
|
||
|
||
Then edit `.env` and add your API keys:
|
||
|
||
```bash
|
||
# .env
|
||
OPENAI_API_KEY=your-openai-api-key-here
|
||
GITHUB_ACCESS_TOKEN=your-github-token-here
|
||
|
||
# Optional: Set defaults
|
||
DEFAULT_MODEL=gpt-4o-mini
|
||
DEFAULT_OUTPUT_FILE=llms.txt
|
||
```
|
||
|
||
### Option 2: Using environment variables
|
||
|
||
```bash
|
||
export OPENAI_API_KEY="your-openai-api-key"
|
||
export GITHUB_ACCESS_TOKEN="your-github-token" # Optional
|
||
```
|
||
|
||
### Option 3: Pass keys directly via CLI
|
||
|
||
```bash
|
||
uv run python main.py https://github.com/stanfordnlp/dspy \
|
||
--openai-key "your-key" \
|
||
--github-token "your-token"
|
||
```
|
||
|
||
## Usage
|
||
|
||
### Command Line Interface
|
||
|
||
Basic usage:
|
||
|
||
```bash
|
||
uv run python main.py https://github.com/stanfordnlp/dspy
|
||
```
|
||
|
||
With custom options:
|
||
|
||
```bash
|
||
# Specify output file
|
||
uv run python main.py https://github.com/stanfordnlp/dspy -o output/dspy-llms.txt
|
||
|
||
# Use a different model
|
||
uv run python main.py https://github.com/stanfordnlp/dspy -m gpt-4o
|
||
|
||
# Pass API keys directly
|
||
uv run python main.py https://github.com/stanfordnlp/dspy \
|
||
--openai-key "your-key" \
|
||
--github-token "your-token"
|
||
```
|
||
|
||
### Python API
|
||
|
||
You can also use the generator programmatically:
|
||
|
||
```python
|
||
from src.generator import generate_llms_txt
|
||
|
||
# Generate llms.txt for a repository
|
||
content = generate_llms_txt(
|
||
repo_url="https://github.com/stanfordnlp/dspy",
|
||
output_file="llms.txt",
|
||
model="gpt-4o-mini",
|
||
openai_api_key="your-key", # Optional if env var is set
|
||
github_token="your-token" # Optional
|
||
)
|
||
|
||
print(content)
|
||
```
|
||
|
||
## Project Structure
|
||
|
||
```
|
||
llmstxt-generator/
|
||
|