Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,41 @@ dspy-cli --version

## 2. Create Project

### Interactive Mode (Recommended)

```bash
dspy-cli new email-subject -s "body, sender, context -> subject, tone, priority"
cd email-subject
dspy-cli new
```

You'll be prompted for:
- **Project name:** `email-subject`
- **First program name:** `email_subject` (default, or customize)
- **Module type:** Choose from Predict, ChainOfThought, ReAct, etc.
- **Signature:** `body, sender, context -> subject, tone, priority`
- Type `?` for guided field-by-field input
- **Model:** `openai/gpt-4o-mini` (or any LiteLLM-compatible model)
- **API Key:** Enter your key or press Enter to configure later

**Expected output:**
```
✓ Created project structure
✓ Generated signature: EmailSubjectSignature
✓ Scaffolded module: EmailSubjectPredict
Creating new DSPy project: email-subject
Package name: email_subject
Initial program: email_subject
Module type: Predict
Signature: body, sender, context -> subject, tone, priority
Model: openai/gpt-4o-mini

✓ Project created successfully!
```

### Non-Interactive Mode

```bash
dspy-cli new email-subject -s "body, sender, context -> subject, tone, priority"
cd email-subject
```

Configure environment:
Configure environment (if not done during creation):

```bash
echo "OPENAI_API_KEY=sk-..." > .env
Expand Down
29 changes: 18 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

## Overview

dspy-cli is a deployment framework for LLM-backed application features. It generates standardized project structure and HTTP interfaces for DSPy modules, reducing setup time from hours to minutes.
`dspy-cli` helps you quickly create, evolve, and deploy [DSPy](https://dspy.ai/) programs. It generates a standardized project structure and HTTP interfaces for DSPy modules, reducing the time required to deploy an AI-powered endpoint.

`dspy-cli` has three main functions:

- `new`: Creates a new project, after walking you through a few questions. `new` sets up directory structure, an initial program, configuration, and a Dockerfile.
- `generate`: Creates additional programs, signatures, and modules. Running `generate signature` creates a signature and module according to any provided parameters, with the necessary import statements.
- `serve`: Stands up an HTTP API with endpoints for all modules and a web UI for calling them. The `serve` command auto-detects modules at run time and hot-reloads as files are updated.

## The Problem

Expand All @@ -12,10 +18,10 @@ Embedding LLM-backed features into applications requires:
- Exposing a stable HTTP interface
- Wiring API keys and secrets
- Implementing health checks and logging
- Configuring routing and auto-discovery
- Configuring routing
- Setting up local development and testing infrastructure

This overhead blocks small-to-medium AI features from shipping. A DSPy module that takes 30 minutes to write can require 4+ hours of infrastructure work before it's usable in a browser extension, Notion plugin, or web application.
This overhead blocks small-to-medium AI features from shipping. A DSPy module that takes 30 minutes to write can require hours of infrastructure work before it's usable in a browser extension, Notion integration, chat plugin, or web application.

## What dspy-cli Provides

Expand All @@ -26,13 +32,13 @@ This overhead blocks small-to-medium AI features from shipping. A DSPy module th

**HTTP Interface**
- FastAPI-based REST endpoints with automatic module discovery
- OpenAPI documentation and interactive testing UI
- Request/response validation via Pydantic models
- OpenAPI documentation and interactive testing UI {fix}
- Request/response validation via Pydantic models {fix}

**Development Workflow**
- Hot-reload server for rapid iteration
- Built-in testing UI with form-based request construction
- Type-safe module signatures with validation
- Type-safe module signatures with validation {repetitive}

**Deployment Infrastructure**
- Production-ready Docker containers
Expand Down Expand Up @@ -88,15 +94,16 @@ Modules in `src/*/modules/` are automatically registered as endpoints at `/{Modu
# Install
uv tool install dspy-cli

# Create project
# Create project (interactive mode - recommended)
dspy-cli new

# Or with arguments
dspy-cli new my-feature -s "text -> summary"
cd my-feature && uv sync

# Configure
echo "OPENAI_API_KEY=sk-..." > .env
cd my-feature && uv sync

# Serve locally
dspy-cli serve --ui
dspy-cli serve
```

Access the API at `http://localhost:8000/{ModuleName}` and testing UI at `http://localhost:8000/`.
Expand Down
14 changes: 1 addition & 13 deletions src/dspy_cli/commands/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@

from dspy_cli.config.validator import find_package_directory, validate_project_structure
from dspy_cli.utils.signature_utils import parse_signature_string, to_class_name, build_forward_components


# Map of module type aliases to their canonical names and template files
MODULE_TYPES = {
"Predict": {"template": "module_predict.py.template", "suffix": "predict"},
"ChainOfThought": {"template": "module_chain_of_thought.py.template", "suffix": "cot"},
"CoT": {"template": "module_chain_of_thought.py.template", "suffix": "cot"},
"ProgramOfThought": {"template": "module_program_of_thought.py.template", "suffix": "pot"},
"PoT": {"template": "module_program_of_thought.py.template", "suffix": "pot"},
"ReAct": {"template": "module_react.py.template", "suffix": "react"},
"MultiChainComparison": {"template": "module_multi_chain_comparison.py.template", "suffix": "mcc"},
"Refine": {"template": "module_refine.py.template", "suffix": "refine"},
}
from dspy_cli.utils.constants import MODULE_TYPES


@click.group(name="generate")
Expand Down
Loading
Loading