3.7 KiB
3.7 KiB
TypeAgent Quick Start
Get started with TypeAgent in 5 minutes.
Prerequisites
- Rust toolchain (1.75+)
- Anthropic API key
Setup
1. Set API Key
export ANTHROPIC_API_KEY=your-api-key-here
2. Build TypeAgent
cd crates/typedialog-agent/typedialog-ag
cargo build --release
3. Add to PATH (optional)
export PATH="$PWD/target/release:$PATH"
Your First Agent
Create an Agent File
Create hello.agent.mdx:
---
@agent {
role: friendly assistant,
llm: claude-3-5-haiku-20241022
}
@input name: String
---
Say hello to {{ name }} in a creative and friendly way!
Run It
typeagent hello.agent.mdx
You'll see:
🤖 TypeAgent Executor
✓ Parsed agent definition
✓ Transpiled to Nickel
✓ Evaluated agent definition
Agent Configuration:
Role: friendly assistant
Model: claude-3-5-haiku-20241022
Max tokens: 4096
Temperature: 0.7
name (String): Alice█
Type a name and press Enter. The agent will execute and show the response!
Next Steps
Try the Examples
# Simple greeting
typeagent tests/fixtures/simple.agent.mdx --yes
# Creative haiku
typeagent tests/fixtures/haiku.agent.mdx
Validate Before Running
typeagent validate hello.agent.mdx
See the Nickel Code
typeagent transpile hello.agent.mdx
Common Workflows
Development Workflow
# 1. Write your agent
vim agent.mdx
# 2. Validate it
typeagent validate agent.mdx
# 3. Test with verbose output
typeagent agent.mdx --verbose
# 4. Run in production
typeagent agent.mdx
Quick Iteration
Use --yes to skip prompts during development:
# Edit agent.mdx
# Run without prompts
typeagent agent.mdx --yes
Advanced Features
Context Injection
Import files into your agent:
@import "./docs/**/*.md" as documentation
@shell "git log --oneline -5" as recent_commits
Output Validation
Ensure output meets requirements:
@validate output {
must_contain: ["Security", "Performance"],
format: markdown,
min_length: 100
}
Conditional Logic
Use Tera template syntax:
{% if has_description %}
Description: {{ description }}
{% endif %}
Troubleshooting
"ANTHROPIC_API_KEY not set"
export ANTHROPIC_API_KEY=sk-ant-...
"Failed to parse agent MDX"
Check your frontmatter syntax:
---
@agent {
role: assistant, # <- comma required
llm: claude-3-5-haiku-20241022
}
---
"Permission denied"
chmod +x ./target/release/typeagent
Learn More
Support
- GitHub Issues: https://github.com/jesusperezlorenzo/typedialog/issues
- API Docs:
cargo doc --open --package typedialog-ag-core
Next Example: Architecture Agent
Create architect.agent.mdx:
---
@agent {
role: software architect,
llm: claude-3-5-sonnet-20241022
}
@input feature_name: String
@input requirements?: String
@validate output {
must_contain: ["## Architecture", "## Components"],
format: markdown,
min_length: 200
}
---
# Architecture Design: {{ feature_name }}
You are an experienced software architect. Design a comprehensive architecture for:
**Feature**: {{ feature_name }}
{% if requirements %}
**Requirements**: {{ requirements }}
{% endif %}
Provide:
1. High-level architecture overview
2. Component breakdown
3. Data flow
4. Technology recommendations
Use clear markdown formatting with sections.
Run it:
typeagent architect.agent.mdx
The agent will prompt for inputs and generate a complete architecture design!