Step 06: Recipe
0 studying now
advanced 60 min
Recipe
YAML 기반 Recipe 파싱과 템플릿 치환을 학습합니다.
Execute this step
Run from step folder:
cd steps/06_recipe && cargo runRun from project root:
cargo run -p step06_recipeStep 6: Recipe
학습 목표
- YAML 파싱, 템플릿 치환, parameters
참조 소스
| 파일 | 내용 |
|------|------|
| crates/goose/src/recipe/mod.rs | Recipe 모듈 |
| crates/goose/src/recipe/template_recipe.rs | Template Recipe 구현 |
핵심 개념
Recipe는 Agent의 동작을 YAML로 정의하는 방법입니다. 재사용 가능한 워크플로우를 만들 수 있습니다.
Recipe YAML 구조
1name: summarize 2description: Summarize a document 3parameters: 4 - name: file_path 5 description: Path to the file 6prompt: | 7 Read the file at {{file_path}} and provide a summary.
Template 치환
Template 변수({{variable}})는 실행 시 실제 값으로 치환됩니다. minijinja를 사용합니다.
1// Recipe 로드 2let recipe = Recipe::from_file("summarize.yaml")?; 3 4// Parameters 치환 5let prompt = recipe.render(params)?; 6// "Read the file at ./README.md and provide a summary."
Recipe 구조체
1pub struct Recipe { 2 pub title: String, 3 pub instructions: Vec<String>, 4 pub prompt: String, 5 pub extensions: Vec<ExtensionConfig>, 6}
소스 코드
1//! Sample Step 6: Recipe 2 3fn main() { 4 println!("=== Step 6: Recipe ===\n"); 5 println!("TODO: YAML 파싱, 템플릿 치환"); 6}
체크리스트
- [ ] Recipe YAML 구조 이해
- [ ] 템플릿 변수 치환 방법 파악
- [ ] parameters와 default 값 처리
- [ ] Recipe 실행 흐름 분석