Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
4 changes: 2 additions & 2 deletions docs/source/ko/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
# title: (λ²ˆμ—­μ€‘) Build a web browser agent using vision models
# - local: examples/using_different_models
# title: (λ²ˆμ—­μ€‘) Using different models
# - local: examples/plan_customization
# title: "(λ²ˆμ—­μ€‘) Human-in-the-Loop: Customize agent plan interactively"
- local: examples/plan_customization
title: Human-in-the-Loop: μ‚¬μš©μžμ™€ μƒν˜Έμž‘μš©ν•˜λ©° μ—μ΄μ „νŠΈ κ³„νš μˆ˜μ •ν•˜κΈ°
# - local: examples/async_agent
# title: (λ²ˆμ—­μ€‘) Async Applications with Agents
- title: Reference
Expand Down
118 changes: 118 additions & 0 deletions docs/source/ko/examples/plan_customization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Human-in-the-Loop: μ‚¬μš©μžμ™€ μƒν˜Έμž‘μš©ν•˜λ©° μ—μ΄μ „νŠΈ κ³„νš μˆ˜μ •ν•˜κΈ° [[humanintheloop-customize-agent-plan-interactively]]

이 νŽ˜μ΄μ§€μ—μ„œλŠ” smolagents 라이브러리의 κ³ κΈ‰ μ‚¬μš©λ²•μ„ μ†Œκ°œν•©λ‹ˆλ‹€. 특히 μ‚¬μš©μžμ™€μ˜ μƒν˜Έμž‘μš©μ„ ν†΅ν•œ κ³„νš 생성, κ³„νš μˆ˜μ •, 그리고 μ—μ΄μ „νŠΈ μ›Œν¬ν”Œλ‘œμ—μ„œμ˜ λ©”λͺ¨λ¦¬ 보쑴을 μœ„ν•œ Human-in-the-Loop (HITL) μ ‘κ·Ό 방식을 μ€‘μ μ μœΌλ‘œ μ„€λͺ…ν•©λ‹ˆλ‹€.
μ˜ˆμ œλŠ” `examples/plan_customization/plan_customization.py`의 μ½”λ“œλ₯Ό 기반으둜 ν•©λ‹ˆλ‹€.

## κ°œμš” [[overview]]

이 μ˜ˆμ œλŠ” λ‹€μŒκ³Ό 같은 Human-in-the-Loop μ „λž΅μ„ κ΅¬ν˜„ν•˜λŠ” 방법을 μ•ˆλ‚΄ν•©λ‹ˆλ‹€.

- 단계 콜백(step callback)을 μ‚¬μš©ν•˜μ—¬ κ³„νš 생성 ν›„ μ—μ΄μ „νŠΈ μ‹€ν–‰ μ€‘λ‹¨ν•˜κΈ°
- μ‚¬μš©μžκ°€ μ‹€ν–‰ 전에 μ—μ΄μ „νŠΈμ˜ κ³„νšμ„ κ²€ν† ν•˜κ³  μˆ˜μ •ν•  수 μžˆλ„λ‘ 지원 (Human-in-the-Loop)
- μ—μ΄μ „νŠΈμ˜ λ©”λͺ¨λ¦¬λ₯Ό λ³΄μ‘΄ν•˜λ©΄μ„œ μ‹€ν–‰ μž¬κ°œν•˜κΈ°
- μ‚¬μš©μž ν”Όλ“œλ°±μ„ 기반으둜 κ³„νšμ„ λ™μ μœΌλ‘œ μ—…λ°μ΄νŠΈν•˜μ—¬ μ‚¬μš©μžκ°€ μ œμ–΄κΆŒμ„ μœ μ§€ν•˜λ„λ‘ 지원

## 핡심 κ°œλ… [[key-concepts]]

### 단계 μ½œλ°±μ„ μ΄μš©ν•œ κ³„νš 쀑단 [[step-callbacks-for-plan-interruption]]

μ—μ΄μ „νŠΈκ°€ κ³„νšμ„ μƒμ„±ν•œ ν›„ μΌμ‹œ μ€‘μ§€ν•˜λ„λ‘ μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” PlanningStep에 단계 μ½œλ°±μ„ λ“±λ‘ν•˜μ—¬ κ΅¬ν˜„ν•©λ‹ˆλ‹€.

```python
agent = CodeAgent(
model=InferenceClientModel(),
tools=[DuckDuckGoSearchTool()],
planning_interval=5, # 5λ‹¨κ³„λ§ˆλ‹€ κ³„νš
step_callbacks={PlanningStep: interrupt_after_plan},
max_steps=10,
verbosity_level=1
)
```

### Human-in-the-Loop: λŒ€ν™”ν˜• κ³„νš κ²€ν†  및 μˆ˜μ • [[humanintheloop-interactive-plan-review-and-modification]]

μ—μ΄μ „νŠΈκ°€ κ³„νšμ„ μƒμ„±ν•˜λ©΄, 콜백 ν•¨μˆ˜κ°€ ν•΄λ‹Ή κ³„νšμ„ μ‚¬μš©μžμ—κ²Œ 보여주고 λ‹€μŒ μ˜΅μ…˜ 쀑 ν•˜λ‚˜λ₯Ό μ„ νƒν•˜λ„λ‘ μ•ˆλ‚΄ν•©λ‹ˆλ‹€.

1. κ³„νš 승인
2. κ³„νš μˆ˜μ •
3. μ‹€ν–‰ μ·¨μ†Œ

예제 μƒν˜Έμž‘μš©:

```
============================================================
πŸ€– μ—μ΄μ „νŠΈ κ³„νš 생성됨
============================================================
1. 졜근 AI λ°œμ „ 사항 검색
2. μƒμœ„ κ²°κ³Ό 뢄석
3. κ°€μž₯ μ€‘μš”ν•œ 3κ°€μ§€ 돌파ꡬ μš”μ•½
4. 각 λŒνŒŒκ΅¬μ— λŒ€ν•œ μ†ŒμŠ€ 포함
============================================================

μ˜΅μ…˜μ„ μ„ νƒν•˜μ„Έμš”:
1. κ³„νš 승인
2. κ³„νš μˆ˜μ •
3. μ·¨μ†Œ
선택 (1-3):
```

이 Human-in-the-Loop 단계λ₯Ό 톡해 μ‚¬μš©μžλŠ” 싀행이 κ³„μ†λ˜κΈ° 전에 κ°œμž…ν•˜μ—¬ κ³„νšμ„ κ²€ν† ν•˜κ³  μˆ˜μ •ν•  수 있으며, 이λ₯Ό 톡해 μ—μ΄μ „νŠΈμ˜ 행동이 μ‚¬μš©μžμ˜ μ˜λ„μ™€ μΌμΉ˜ν•˜λ„λ‘ 보μž₯ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ‚¬μš©μžκ°€ μˆ˜μ •μ„ μ„ νƒν•˜λ©΄ κ³„νšμ„ 직접 νŽΈμ§‘ν•  수 있으며, μ—…λ°μ΄νŠΈλœ κ³„νšμ€ 이후 μ‹€ν–‰ λ‹¨κ³„μ—μ„œ μ‚¬μš©λ©λ‹ˆλ‹€.

### λ©”λͺ¨λ¦¬ 보쑴 및 μ‹€ν–‰ 재개 [[memory-preservation-and-resuming-execution]]

`reset=False` μ˜΅μ…˜μœΌλ‘œ μ—μ΄μ „νŠΈλ₯Ό μ‹€ν–‰ν•˜λ©΄ μ΄μ „μ˜ λͺ¨λ“  단계와 λ©”λͺ¨λ¦¬κ°€ λ³΄μ‘΄λ©λ‹ˆλ‹€. 이λ₯Ό 톡해 쀑단 λ˜λŠ” κ³„νš μˆ˜μ • 후에도 싀행을 μ΄μ–΄μ„œ μ§„ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

```python
# 첫 번째 μ‹€ν–‰ (쀑단될 수 있음)
agent.run(task, reset=True)

# 보쑴된 λ©”λͺ¨λ¦¬λ‘œ 재개
agent.run(task, reset=False)
```

### μ—μ΄μ „νŠΈ λ©”λͺ¨λ¦¬ 검사 [[inspecting-agent-memory]]

μ—μ΄μ „νŠΈμ˜ λ©”λͺ¨λ¦¬λ₯Ό κ²€μ‚¬ν•˜μ—¬ μ§€κΈˆκΉŒμ§€ μˆ˜ν–‰λœ λͺ¨λ“  단계λ₯Ό 확인할 수 μžˆμŠ΅λ‹ˆλ‹€:

```python
print(f"ν˜„μž¬ λ©”λͺ¨λ¦¬μ— {len(agent.memory.steps)}개의 단계가 ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€:")
for i, step in enumerate(agent.memory.steps):
step_type = type(step).__name__
print(f" {i+1}. {step_type}")
```

## Human-in-the-Loop μ›Œν¬ν”Œλ‘œμš° μ˜ˆμ‹œ [[example-humanintheloop-workflow]]

1. μ—μ΄μ „νŠΈκ°€ λ³΅μž‘ν•œ μž‘μ—…μ„ λ°›μ•„ 싀행을 μ‹œμž‘ν•©λ‹ˆλ‹€.
2. κ³„νš 단계가 μƒμ„±λ˜κ³ , μ‚¬μš©μž κ²€ν† λ₯Ό μœ„ν•΄ 싀행이 μΌμ‹œ μ€‘μ§€λ©λ‹ˆλ‹€.
3. μ‚¬μš©μžκ°€ κ³„νšμ„ κ²€ν† ν•˜κ³  ν•„μš”μ— 따라 μˆ˜μ •ν•©λ‹ˆλ‹€ (Human-in-the-Loop).
4. μŠΉμΈλ˜κ±°λ‚˜ μˆ˜μ •λœ κ³„νšμœΌλ‘œ 싀행을 μž¬κ°œν•©λ‹ˆλ‹€.
5. λͺ¨λ“  λ‹¨κ³„λŠ” ν–₯ν›„ 싀행을 μœ„ν•΄ λ³΄μ‘΄λ˜μ–΄ 투λͺ…μ„±κ³Ό μ œμ–΄κΆŒμ„ 보μž₯ν•©λ‹ˆλ‹€.

## 였λ₯˜ 처리 [[error-handling]]

μ˜ˆμ œλŠ” λ‹€μŒμ— λŒ€ν•œ 였λ₯˜ 처리λ₯Ό ν¬ν•¨ν•©λ‹ˆλ‹€:
- μ‚¬μš©μž μ·¨μ†Œ
- κ³„νš μˆ˜μ • 였λ₯˜
- μ‹€ν–‰ 재개 μ‹€νŒ¨

## μš”κ΅¬μ‚¬ν•­ [[requirements]]

- smolagents 라이브러리
- DuckDuckGoSearchTool (smolagents에 포함)
- InferenceClientModel (πŸ€— Hugging Face API 토큰 ν•„μš”)

## ꡐ윑적 κ°€μΉ˜ [[educational-value]]

이 μ˜ˆμ œλŠ” λ‹€μŒμ„ μ‹œμ—°ν•©λ‹ˆλ‹€:
- μ‚¬μš©μž μ •μ˜ μ—μ΄μ „νŠΈ λ™μž‘μ„ μœ„ν•œ 단계 콜백 κ΅¬ν˜„ 방법
- 닀쀑 단계 μ—μ΄μ „νŠΈμ˜ λ©”λͺ¨λ¦¬ 관리 기법
- μ—μ΄μ „νŠΈ μ‹œμŠ€ν…œμ˜ μ‚¬μš©μž μƒν˜Έμž‘μš© νŒ¨ν„΄
- 동적 μ—μ΄μ „νŠΈ μ œμ–΄λ₯Ό μœ„ν•œ κ³„νš μˆ˜μ • 기법
- λŒ€ν™”ν˜• μ—μ΄μ „νŠΈ μ‹œμŠ€ν…œμ˜ 였λ₯˜ 처리 방법

---

전체 μ½”λ“œλŠ” [`examples/plan_customization`](https://github.com/huggingface/smolagents/tree/main/examples/plan_customization)μ—μ„œ ν™•μΈν•˜μ„Έμš”.