Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:27:31 +08:00
commit b3b538c011
38 changed files with 5130 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
# Agent Templates
Templates for agent patterns (planning, execution, multi-agent, etc.)
## Pattern Structure
Each agent template includes:
- Task and plan types
- State management structures
- Planning/execution functions
- Tool usage patterns
- Example test cases
## Common Use Cases
- Planning agents
- Execution agents
- Multi-agent workflows
- Task automation
- Decision-making systems

View File

@@ -0,0 +1,20 @@
# Classification Templates
Templates for classification patterns (sentiment, intent, category, etc.)
## Pattern Structure
Each classification template includes:
- Input types (usually text)
- Enum definitions for categories
- Classification function with confidence
- Reasoning capture
- Example test cases
## Common Use Cases
- Sentiment analysis
- Intent detection
- Category assignment
- Priority classification
- Topic identification

View File

@@ -0,0 +1,35 @@
// Example: Sentiment Classification Pattern
enum Sentiment {
Positive @description("Positive sentiment")
Negative @description("Negative sentiment")
Neutral @description("Neutral sentiment")
}
class SentimentResult {
sentiment Sentiment
confidence float @description("Confidence score 0-1")
reasoning string @description("Explanation for classification")
}
client FastModel {
provider "openai"
options {
model "gpt-4o-mini"
temperature 0.1
}
}
function ClassifySentiment(text: string) -> SentimentResult {
client FastModel
prompt #"
Classify the sentiment of the following text:
{{ text }}
Provide confidence score and reasoning.
{{ ctx.output_format }}
"#
}

View File

@@ -0,0 +1,20 @@
# Extraction Templates
Templates for data extraction patterns (invoice, resume, receipt, etc.)
## Pattern Structure
Each extraction template includes:
- Input types (often image or text)
- Output class definitions (structured data)
- Extraction function with detailed prompt
- Validation rules
- Example test cases
## Common Use Cases
- Invoice extraction
- Resume parsing
- Receipt processing
- Document analysis
- Form extraction

View File

@@ -0,0 +1,44 @@
// Example: Invoice Extraction Pattern
// This template extracts structured invoice data from images
class LineItem {
description string @description("Item description")
quantity int @description("Number of units")
unit_price float @description("Price per unit")
total float @description("Line item total")
}
class Invoice {
invoice_number string @description("Invoice ID")
date string @description("Invoice date (YYYY-MM-DD)")
vendor_name string
items LineItem[] @description("List of line items")
subtotal float
tax float
total float @description("Grand total")
}
client VisionModel {
provider "openai"
options {
model "gpt-4o"
temperature 0.0
}
}
function ExtractInvoice(invoice_image: image) -> Invoice {
client VisionModel
prompt #"
Extract all information from this invoice image.
{{ invoice_image }}
IMPORTANT:
- Validate that subtotal + tax = total
- Extract all line items accurately
- Use YYYY-MM-DD format for dates
{{ ctx.output_format }}
"#
}

View File

@@ -0,0 +1,38 @@
# Integration Templates
Framework-specific integration code templates
## Supported Frameworks
### Python
- FastAPI
- Flask
- Django
### TypeScript
- Next.js
- Express
- NestJS
### Ruby
- Rails
- Sinatra
### Java
- Spring Boot
### Go
- Gin
- Echo
### C#
- ASP.NET Core
## Template Structure
Each integration template includes:
- API endpoint/route
- Request/response models
- Error handling
- Async patterns
- Configuration examples

20
templates/rag/README.md Normal file
View File

@@ -0,0 +1,20 @@
# RAG Templates
Templates for Retrieval-Augmented Generation patterns (search, citation, etc.)
## Pattern Structure
Each RAG template includes:
- Document/context types
- Citation tracking structures
- Search functions with source attribution
- Confidence scoring
- Example test cases
## Common Use Cases
- Citation-aware search
- Source-attributed responses
- Context-based generation
- Document retrieval
- Knowledge base querying