Ver3.0 ๐ Python + Claude API๋ก ํ๋กฌํํธ ํ๊ฐ ๋๊ตฌ ๋ง๋ค๊ธฐ

๐ Python + Claude API๋ก ํ๋กฌํํธ ํ๊ฐ ๋๊ตฌ ๋ง๋ค๊ธฐ
๐ฏ ์ ํ๋กฌํํธ ํ๊ฐ ๋๊ตฌ๊ฐ ํ์ํ ๊น?
์์ฆ AI ๊ฐ๋ฐ์๋ผ๋ฉด ๋๊ตฌ๋ ๊ณ ๋ฏผํ๋ ๊ฒ ์์ด. ๋ฐ๋ก "๋ด๊ฐ ์์ฑํ ํ๋กฌํํธ๊ฐ ์ ๋ง ์ข์ ๊ฑธ๊น?"๋ผ๋ ์ง๋ฌธ์ด์ง. ๐ChatGPT, Claude, GPT-4 ๊ฐ์ ๋ํ ์ธ์ด ๋ชจ๋ธ(LLM)์ ์ฌ์ฉํ ๋, ํ๋กฌํํธ์ ํ์ง์ด ๊ฒฐ๊ณผ๋ฌผ์ 90%๋ฅผ ์ข์ฐํ๋ค๊ณ ํด๋ ๊ณผ์ธ์ด ์๋์ผ. ๊ทผ๋ฐ ๋ฌธ์ ๋ ํ๋กฌํํธ๋ฅผ ์์ฑํ ๋๋ง๋ค "์ด๊ฒ ๋ง๋?" ์ถ์ ๊ฑฐ์ง.
โข ์ง์์ฌํญ์ด ๋๋ฌด ๊ธธ์ด์ ํต์ฌ์ด ๋ฌปํ๋ ๊ฒฝ์ฐ
โข ์ฌ๋ฌ ๋ฒ์ ์ ํ๋กฌํํธ ์ค ์ด๋ค ๊ฒ ๋ ๋์์ง ๊ฐ๊ด์ ์ผ๋ก ๋น๊ตํ๊ธฐ ์ด๋ ค์ด ๊ฒฝ์ฐ
โข ํ์๋ค๊ณผ ํ๋กฌํํธ ํ์ง ๊ธฐ์ค์ ๊ณต์ ํ๊ธฐ ์ด๋ ค์ด ๊ฒฝ์ฐ
์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ AI ๊ด๋ จ ์๋น์ค๋ฅผ ์ ๊ณตํ๋ ๊ฐ๋ฐ์๋ค์๊ฒ๋ ์ด๋ฐ ๋๊ตฌ๋ ์ ๋ง ์ ์ฉํด. ํด๋ผ์ด์ธํธ์๊ฒ "์ฐ๋ฆฌ๋ ์ด๋ ๊ฒ ์ฒด๊ณ์ ์ผ๋ก ํ๋กฌํํธ๋ฅผ ๊ด๋ฆฌํฉ๋๋ค"๋ผ๊ณ ๋ณด์ฌ์ค ์ ์์ผ๋๊น!
๐ ํ๋กฌํํธ ํ๊ฐ์ ํต์ฌ ์งํ๋ค
ํ๋กฌํํธ๋ฅผ ํ๊ฐํ๋ค๋ ๊ฑด ๊ตฌ์ฒด์ ์ผ๋ก ๋ญ ์ธก์ ํ๋ค๋ ๊ฑธ๊น? ํ๊ณ์ ์ ๊ณ์์ ํฉ์๋ ๋ช ๊ฐ์ง ํต์ฌ ์งํ๋ค์ด ์์ด.1๏ธโฃ ๋ช ํ์ฑ (Clarity)
ํ๋กฌํํธ๊ฐ ์ผ๋ง๋ ๋ถ๋ช ํ๊ณ ์ดํดํ๊ธฐ ์ฌ์ด๊ฐ๋ฅผ ์ธก์ ํด. ์ ๋งค๋ชจํธํ ํํ์ด๋ ์ค์์ ์ธ ๋ฌธ์ฅ์ด ์์ผ๋ฉด ์ ์๊ฐ ๋ฎ์์ง์ง."๊ทธ๊ฒ์ ๋ํด ์ค๋ช ํด์ค"
โ ๋ช ํ์ฑ์ด ๋์ ์์:
"Python์ ๋ฆฌ์คํธ ์ปดํ๋ฆฌํจ์ ๋ฌธ๋ฒ์ ์ด๋ณด์๋ ์ดํดํ ์ ์๋๋ก ์์ ์ฝ๋์ ํจ๊ป ์ค๋ช ํด์ค"
2๏ธโฃ ๊ตฌ์ฒด์ฑ (Specificity)
์์ฒญ์ด ์ผ๋ง๋ ๊ตฌ์ฒด์ ์ธ์ง๋ฅผ ํ๊ฐํด. ์ธ๋ถ ์กฐ๊ฑด, ์ ์ฝ์ฌํญ, ์ํ๋ ํ์ ๋ฑ์ด ๋ช ์๋์ด ์์์๋ก ์ข์.3๏ธโฃ ๋งฅ๋ฝ ์ ๊ณต (Context)
AI๊ฐ ์์ ์ ์ํํ๋ ๋ฐ ํ์ํ ๋ฐฐ๊ฒฝ ์ ๋ณด๊ฐ ์ถฉ๋ถํ ์ ๊ณต๋์๋์ง ํ์ธํด. ๋งฅ๋ฝ์ด ํ๋ถํ ์๋ก AI๋ ๋ ์ ํํ ๋ต๋ณ์ ์์ฑํ ์ ์์ด.4๏ธโฃ ๊ตฌ์กฐํ (Structure)
ํ๋กฌํํธ๊ฐ ๋ ผ๋ฆฌ์ ์ผ๋ก ์ ๊ตฌ์ฑ๋์ด ์๋์ง ํ๊ฐํด. ๋จ๊ณ๋ณ ์ง์์ฌํญ, ๋ฒํธ ๋งค๊ธฐ๊ธฐ, ์น์ ๊ตฌ๋ถ ๋ฑ์ด ์์ผ๋ฉด ์ ์๊ฐ ์ฌ๋ผ๊ฐ์ง.5๏ธโฃ ์ ์ฝ์กฐ๊ฑด ๋ช ์ (Constraints)
์ถ๋ ฅ ํ์, ๊ธธ์ด ์ ํ, ํค์ค๋งค๋, ๊ธ์ง ์ฌํญ ๋ฑ์ด ๋ช ํํ ์ ์๋์ด ์๋์ง ํ์ธํด.| ํ๊ฐ ์งํ | ์ธก์ ๋ด์ฉ | ์ ์ ๋ฒ์ |
|---|---|---|
| ๋ช ํ์ฑ | ์๋ฏธ์ ๋ถ๋ช ํจ, ์ ๋งค๋ชจํธํจ ์ ๊ฑฐ | 0-10 |
| ๊ตฌ์ฒด์ฑ | ์ธ๋ถ ์กฐ๊ฑด ๋ฐ ์๊ตฌ์ฌํญ ๋ช ์ | 0-10 |
| ๋งฅ๋ฝ ์ ๊ณต | ๋ฐฐ๊ฒฝ ์ ๋ณด ๋ฐ ์ํฉ ์ค๋ช | 0-10 |
| ๊ตฌ์กฐํ | ๋ ผ๋ฆฌ์ ๊ตฌ์ฑ ๋ฐ ๋จ๊ณ๋ณ ์ ๋ฆฌ | 0-10 |
| ์ ์ฝ์กฐ๊ฑด | ์ถ๋ ฅ ํ์ ๋ฐ ์ ํ์ฌํญ ๋ช ์ | 0-10 |
๐ ๏ธ ๊ฐ๋ฐ ํ๊ฒฝ ์ค๋นํ๊ธฐ
์, ์ด์ ๋ณธ๊ฒฉ์ ์ผ๋ก ๋๊ตฌ๋ฅผ ๋ง๋ค์ด๋ณด์! ๋จผ์ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ธํ ํด์ผ ํด.ํ์ํ ๊ฒ๋ค ์ฒดํฌ๋ฆฌ์คํธ โ
์ต์ ๋ฒ์ ์ ๊ถ์ฅํด. Python 3.10์ด๋ 3.11์ด๋ฉด ์๋ฒฝํด!
# ๋ฒ์ ํ์ธ
python --version
# ๋๋
python3 --version
Anthropic ์น์ฌ์ดํธ(console.anthropic.com)์ ๊ฐ์ ํ๊ณ API ํค๋ฅผ ๋ฐ๊ธ๋ฐ์์ผ ํด. ๋ฌด๋ฃ ํฌ๋ ๋ง๋ ์ ๊ณต๋๋๊น ํ ์คํธํ๊ธฐ ์ข์! ๐ณ
pip install anthropic python-dotenv requests
๊ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ญํ :โข anthropic: Claude API ๊ณต์ Python SDK
โข python-dotenv: ํ๊ฒฝ ๋ณ์ ๊ด๋ฆฌ
โข requests: HTTP ์์ฒญ ์ฒ๋ฆฌ (์ ํ์ฌํญ)
prompt-evaluator/
โโโ .env # API ํค ์ ์ฅ
โโโ evaluator.py # ๋ฉ์ธ ํ๊ฐ ๋ก์ง
โโโ prompts.py # ํ๊ฐ์ฉ ํ๋กฌํํธ ํ
ํ๋ฆฟ
โโโ utils.py # ์ ํธ๋ฆฌํฐ ํจ์๋ค
โโโ requirements.txt # ์์กด์ฑ ๋ชฉ๋ก
โโโ examples/ # ํ
์คํธ์ฉ ํ๋กฌํํธ ์์
โโโ good_prompts.txt
โโโ bad_prompts.txt
๐ API ํค ์์ ํ๊ฒ ๊ด๋ฆฌํ๊ธฐ
์ฝ๋ฉ ์์ํ๊ธฐ ์ ์ ๊ฐ์ฅ ์ค์ํ ๋ณด์ ์ค์ ๋ถํฐ ํด๋ณด์!ํ๋ก์ ํธ ๋ฃจํธ ๋๋ ํ ๋ฆฌ์
.env ํ์ผ์ ๋ง๋ค์ด:# .env
ANTHROPIC_API_KEY=your_api_key_here
MODEL_NAME=claude-3-sonnet-20240229
MAX_TOKENS=2000
Git์ ์ฌ์ฉํ๋ค๋ฉด ๋ฐ๋์ .env ํ์ผ์ ์ ์ธ์์ผ์ผ ํด:
# .gitignore
.env
__pycache__/
*.pyc
.vscode/
.idea/
from dotenv import load_dotenv
import os
# .env ํ์ผ ๋ก๋
load_dotenv()
# API ํค ๊ฐ์ ธ์ค๊ธฐ
api_key = os.getenv('ANTHROPIC_API_KEY')
model_name = os.getenv('MODEL_NAME', 'claude-3-sonnet-20240229') # ๊ธฐ๋ณธ๊ฐ ์ค์
if not api_key:
raise ValueError("API ํค๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. .env ํ์ผ์ ํ์ธํ์ธ์!")
๐จ ํ๊ฐ ํ๋กฌํํธ ํ ํ๋ฆฟ ์ค๊ณํ๊ธฐ
์ด์ ํต์ฌ ๋ถ๋ถ์ด์ผ! Claude์๊ฒ "์ด ํ๋กฌํํธ๋ฅผ ํ๊ฐํด์ค"๋ผ๊ณ ์์ฒญํ ๋ ์ฌ์ฉํ ๋ฉํ ํ๋กฌํํธ๋ฅผ ๋ง๋ค์ด์ผ ํด. ๐ํ๊ฐ ํ๋กฌํํธ์ ๊ตฌ์กฐ
์ข์ ํ๊ฐ ํ๋กฌํํธ๋ ๋ค์ ์์๋ค์ ํฌํจํด์ผ ํด:2. ํ๊ฐ ๊ธฐ์ค ๋ช ์ - 5๊ฐ์ง ์งํ์ ๊ฐ๊ฐ์ ์๋ฏธ ์ค๋ช
3. ์ถ๋ ฅ ํ์ ์ง์ - JSON์ด๋ ๊ตฌ์กฐํ๋ ํ์์ผ๋ก ๊ฒฐ๊ณผ๋ฅผ ๋ฐ์
4. ์์ ์ ๊ณต - ์ข์/๋์ ํ๋กฌํํธ ์์๋ก ๊ธฐ์ค์ ๋ช ํํ ํจ
์ค์ ์ฝ๋: prompts.py
"""
ํ๋กฌํํธ ํ๊ฐ๋ฅผ ์ํ ํ
ํ๋ฆฟ ๋ชจ์
"""
EVALUATION_PROMPT_TEMPLATE = """๋น์ ์ AI ํ๋กฌํํธ ์์ง๋์ด๋ง ์ ๋ฌธ๊ฐ์
๋๋ค.
์ฃผ์ด์ง ํ๋กฌํํธ๋ฅผ ๋ค์ 5๊ฐ์ง ๊ธฐ์ค์ผ๋ก ํ๊ฐํด์ฃผ์ธ์.
## ํ๊ฐ ๊ธฐ์ค (๊ฐ ํญ๋ชฉ 0-10์ )
1. **๋ช
ํ์ฑ (Clarity)**: ํ๋กฌํํธ์ ์๋์ ์๊ตฌ์ฌํญ์ด ์ผ๋ง๋ ๋ถ๋ช
ํ๊ฐ?
- ์ ๋งค๋ชจํธํ ํํ์ด ์๋๊ฐ?
- ์ค์์ ํด์์ ์ฌ์ง๊ฐ ์๋๊ฐ?
2. **๊ตฌ์ฒด์ฑ (Specificity)**: ์ธ๋ถ ์กฐ๊ฑด๊ณผ ์๊ตฌ์ฌํญ์ด ์ถฉ๋ถํ ๋ช
์๋์๋๊ฐ?
- ๊ตฌ์ฒด์ ์ธ ์์๋ ์กฐ๊ฑด์ด ํฌํจ๋์ด ์๋๊ฐ?
- ์ํ๋ ๊ฒฐ๊ณผ๋ฌผ์ ํํ๊ฐ ๋ช
ํํ๊ฐ?
3. **๋งฅ๋ฝ ์ ๊ณต (Context)**: ์์
์ํ์ ํ์ํ ๋ฐฐ๊ฒฝ ์ ๋ณด๊ฐ ์ถฉ๋ถํ๊ฐ?
- ๊ด๋ จ ๋ฐฐ๊ฒฝ ์ง์์ด๋ ์ํฉ ์ค๋ช
์ด ์๋๊ฐ?
- AI๊ฐ ์์
์ ์ดํดํ๋ ๋ฐ ํ์ํ ์ ๋ณด๊ฐ ์ ๊ณต๋์๋๊ฐ?
4. **๊ตฌ์กฐํ (Structure)**: ํ๋กฌํํธ๊ฐ ๋
ผ๋ฆฌ์ ์ผ๋ก ์ ๊ตฌ์ฑ๋์ด ์๋๊ฐ?
- ๋จ๊ณ๋ณ๋ก ์ ๋ฆฌ๋์ด ์๋๊ฐ?
- ์ฝ๊ธฐ ์ฝ๊ฒ ํฌ๋งทํ
๋์ด ์๋๊ฐ?
5. **์ ์ฝ์กฐ๊ฑด (Constraints)**: ์ถ๋ ฅ ํ์, ๊ธธ์ด, ํค ๋ฑ์ ์ ์ฝ์ด ๋ช
์๋์๋๊ฐ?
- ์ถ๋ ฅ ํ์์ด ์ง์ ๋์ด ์๋๊ฐ?
- ๊ธ์ง ์ฌํญ์ด๋ ์ ํ ์ฌํญ์ด ๋ช
ํํ๊ฐ?
## ํ๊ฐํ ํ๋กฌํํธ:
```
{prompt_to_evaluate}
```
## ์ถ๋ ฅ ํ์:
๋ค์ JSON ํ์์ผ๋ก ํ๊ฐ ๊ฒฐ๊ณผ๋ฅผ ์ ๊ณตํด์ฃผ์ธ์:
{{
"scores": {{
"clarity": <0-10 ์ ์>,
"specificity": <0-10 ์ ์>,
"context": <0-10 ์ ์>,
"structure": <0-10 ์ ์>,
"constraints": <0-10 ์ ์>
}},
"total_score": <์ ์ฒด ํ๊ท ์ ์>,
"grade": "<A/B/C/D/F ๋ฑ๊ธ>",
"strengths": [
"๊ฐ์ 1",
"๊ฐ์ 2"
],
"weaknesses": [
"์ฝ์ 1",
"์ฝ์ 2"
],
"suggestions": [
"๊ฐ์ ์ ์ 1",
"๊ฐ์ ์ ์ 2"
],
"improved_version": "<๊ฐ์ ๋ ํ๋กฌํํธ ๋ฒ์ >"
}}
ํ๊ฐ ์ ๊ฐ๊ด์ ์ด๊ณ ๊ฑด์ค์ ์ธ ํผ๋๋ฐฑ์ ์ ๊ณตํด์ฃผ์ธ์.
"""
# ๊ฐ๋จํ ํ๊ฐ์ฉ (๋น ๋ฅธ ์ ์๋ง ํ์ํ ๋)
QUICK_EVALUATION_TEMPLATE = """๋ค์ ํ๋กฌํํธ๋ฅผ 5๊ฐ์ง ๊ธฐ์ค(๋ช
ํ์ฑ, ๊ตฌ์ฒด์ฑ, ๋งฅ๋ฝ, ๊ตฌ์กฐํ, ์ ์ฝ์กฐ๊ฑด)์ผ๋ก
๊ฐ๊ฐ 0-10์ ์ผ๋ก ํ๊ฐํ๊ณ , JSON ํ์์ผ๋ก ์ ์๋ง ๋ฐํํด์ฃผ์ธ์.
ํ๋กฌํํธ: {prompt_to_evaluate}
์ถ๋ ฅ ํ์:
{{"clarity": X, "specificity": X, "context": X, "structure": X, "constraints": X, "total": X}}
"""
โข JSON ์ถ๋ ฅ ํ์์ ์ง์ ํ๋ฉด ํ์ฑ์ด ํจ์ฌ ์ฌ์์ ธ
โข "๊ฐ์ ๋ ๋ฒ์ "์ ์์ฒญํ๋ฉด ํ์ต ํจ๊ณผ๋ ์๊ณ ์ค์ฉ์ ์ด์ผ!
๐ป ํต์ฌ ํ๊ฐ ์์ง ๊ตฌํํ๊ธฐ
์ด์ ์ค์ ๋ก Claude API๋ฅผ ํธ์ถํ๊ณ ๊ฒฐ๊ณผ๋ฅผ ์ฒ๋ฆฌํ๋ ์ฝ๋๋ฅผ ์์ฑํด๋ณด์!evaluator.py - ๋ฉ์ธ ํด๋์ค
import os
import json
from anthropic import Anthropic
from dotenv import load_dotenv
from prompts import EVALUATION_PROMPT_TEMPLATE, QUICK_EVALUATION_TEMPLATE
class PromptEvaluator:
"""ํ๋กฌํํธ ํ๊ฐ ๋๊ตฌ ๋ฉ์ธ ํด๋์ค"""
def __init__(self, api_key=None):
"""
์ด๊ธฐํ
Args:
api_key (str): Anthropic API ํค. None์ด๋ฉด ํ๊ฒฝ๋ณ์์์ ๋ก๋
"""
load_dotenv()
self.api_key = api_key or os.getenv('ANTHROPIC_API_KEY')
if not self.api_key:
raise ValueError("API ํค๊ฐ ํ์ํฉ๋๋ค!")
self.client = Anthropic(api_key=self.api_key)
self.model = os.getenv('MODEL_NAME', 'claude-3-sonnet-20240229')
self.max_tokens = int(os.getenv('MAX_TOKENS', 2000))
def evaluate(self, prompt_text, quick_mode=False):
"""
ํ๋กฌํํธ ํ๊ฐ ์คํ
Args:
prompt_text (str): ํ๊ฐํ ํ๋กฌํํธ
quick_mode (bool): True๋ฉด ๋น ๋ฅธ ํ๊ฐ (์ ์๋ง)
Returns:
dict: ํ๊ฐ ๊ฒฐ๊ณผ
"""
# ํ
ํ๋ฆฟ ์ ํ
template = QUICK_EVALUATION_TEMPLATE if quick_mode else EVALUATION_PROMPT_TEMPLATE
# ํ๊ฐ ํ๋กฌํํธ ์์ฑ
evaluation_prompt = template.format(prompt_to_evaluate=prompt_text)
try:
# Claude API ํธ์ถ
response = self.client.messages.create(
model=self.model,
max_tokens=self.max_tokens,
messages=[
{
"role": "user",
"content": evaluation_prompt
}
]
)
# ์๋ต ํ
์คํธ ์ถ์ถ
result_text = response.content[0].text
# JSON ํ์ฑ
result = self._parse_result(result_text)
return {
'success': True,
'result': result,
'raw_response': result_text,
'usage': {
'input_tokens': response.usage.input_tokens,
'output_tokens': response.usage.output_tokens
}
}
except Exception as e:
return {
'success': False,
'error': str(e)
}
def _parse_result(self, text):
"""
Claude ์๋ต์์ JSON ์ถ์ถ ๋ฐ ํ์ฑ
Args:
text (str): Claude์ ์๋ต ํ
์คํธ
Returns:
dict: ํ์ฑ๋ ๊ฒฐ๊ณผ
"""
# JSON ๋ธ๋ก ์ฐพ๊ธฐ (```json ... ``` ํ์์ผ ์ ์์)
import re
# JSON ํจํด ์ฐพ๊ธฐ
json_pattern = r'\{[\s\S]*\}'
matches = re.findall(json_pattern, text)
if matches:
# ๊ฐ์ฅ ํฐ JSON ๋ธ๋ก ์ ํ
json_str = max(matches, key=len)
try:
return json.loads(json_str)
except json.JSONDecodeError:
# ํ์ฑ ์คํจ ์ ์๋ณธ ํ
์คํธ ๋ฐํ
return {'raw_text': text}
return {'raw_text': text}
def batch_evaluate(self, prompts_list):
"""
์ฌ๋ฌ ํ๋กฌํํธ๋ฅผ ์ผ๊ด ํ๊ฐ
Args:
prompts_list (list): ํ๊ฐํ ํ๋กฌํํธ ๋ฆฌ์คํธ
Returns:
list: ๊ฐ ํ๋กฌํํธ์ ํ๊ฐ ๊ฒฐ๊ณผ ๋ฆฌ์คํธ
"""
results = []
for i, prompt in enumerate(prompts_list, 1):
print(f"ํ๊ฐ ์ค... ({i}/{len(prompts_list)})")
result = self.evaluate(prompt)
results.append(result)
return results
def compare_prompts(self, prompt1, prompt2):
"""
๋ ํ๋กฌํํธ๋ฅผ ๋น๊ต ํ๊ฐ
Args:
prompt1 (str): ์ฒซ ๋ฒ์งธ ํ๋กฌํํธ
prompt2 (str): ๋ ๋ฒ์งธ ํ๋กฌํํธ
Returns:
dict: ๋น๊ต ๊ฒฐ๊ณผ
"""
result1 = self.evaluate(prompt1)
result2 = self.evaluate(prompt2)
if result1['success'] and result2['success']:
score1 = result1['result'].get('total_score', 0)
score2 = result2['result'].get('total_score', 0)
return {
'prompt1': {
'text': prompt1,
'score': score1,
'details': result1['result']
},
'prompt2': {
'text': prompt2,
'score': score2,
'details': result2['result']
},
'winner': 'prompt1' if score1 > score2 else 'prompt2' if score2 > score1 else 'tie',
'score_difference': abs(score1 - score2)
}
return {
'error': 'ํ๊ฐ ์คํจ',
'result1': result1,
'result2': result2
}
2. ์๋ฌ ํธ๋ค๋ง - try-except๋ก API ํธ์ถ ์คํจ์ ๋๋น
3. JSON ํ์ฑ - ์ ๊ทํํ์์ผ๋ก ์๋ต์์ JSON ์ถ์ถ
4. ๋ฐฐ์น ์ฒ๋ฆฌ - ์ฌ๋ฌ ํ๋กฌํํธ๋ฅผ ํ ๋ฒ์ ํ๊ฐ ๊ฐ๋ฅ
5. ๋น๊ต ๊ธฐ๋ฅ - A/B ํ ์คํธ์ฒ๋ผ ๋ ๋ฒ์ ๋น๊ต
๐ฎ ์ค์ ์ฌ์ฉ ์์
์, ์ด์ ๋ง๋ ๋๊ตฌ๋ฅผ ์ค์ ๋ก ์ฌ์ฉํด๋ณด์! ์ฌ๋ฌ ์๋๋ฆฌ์ค๋ฅผ ์ค๋นํ์ด.์์ 1: ๊ธฐ๋ณธ ํ๊ฐ
from evaluator import PromptEvaluator
# ํ๊ฐ๊ธฐ ์ด๊ธฐํ
evaluator = PromptEvaluator()
# ํ๊ฐํ ํ๋กฌํํธ
test_prompt = """
Python์ผ๋ก ์น ํฌ๋กค๋ฌ๋ฅผ ๋ง๋ค๊ณ ์ถ์ด์.
"""
# ํ๊ฐ ์คํ
result = evaluator.evaluate(test_prompt)
if result['success']:
scores = result['result']['scores']
print(f"์ด์ : {result['result']['total_score']}/10")
print(f"๋ฑ๊ธ: {result['result']['grade']}")
print("\n์ธ๋ถ ์ ์:")
for criterion, score in scores.items():
print(f" {criterion}: {score}/10")
print("\n๊ฐ์ ์ ์:")
for suggestion in result['result']['suggestions']:
print(f" โข {suggestion}")
else:
print(f"ํ๊ฐ ์คํจ: {result['error']}")
์ด์ : 3.2/10
๋ฑ๊ธ: D
์ธ๋ถ ์ ์:
clarity: 4/10
specificity: 2/10
context: 3/10
structure: 4/10
constraints: 3/10
๊ฐ์ ์ ์:
โข ํฌ๋กค๋งํ ์น์ฌ์ดํธ๋ฅผ ๊ตฌ์ฒด์ ์ผ๋ก ๋ช ์ํ์ธ์
โข ์ถ์ถํ๊ณ ์ถ์ ๋ฐ์ดํฐ์ ์ข ๋ฅ๋ฅผ ์ค๋ช ํ์ธ์
โข ์ํ๋ ์ถ๋ ฅ ํ์(CSV, JSON ๋ฑ)์ ์ง์ ํ์ธ์
์์ 2: ๊ฐ์ ๋ ํ๋กฌํํธ์ ๋น๊ต
# ๊ฐ์ ์ ํ๋กฌํํธ
bad_prompt = "Python์ผ๋ก ์น ํฌ๋กค๋ฌ๋ฅผ ๋ง๋ค๊ณ ์ถ์ด์."
# ๊ฐ์ ํ ํ๋กฌํํธ
good_prompt = """
Python๊ณผ BeautifulSoup์ ์ฌ์ฉํ์ฌ ๋ค์ด๋ฒ ๋ด์ค ๊ธฐ์ฌ๋ฅผ ํฌ๋กค๋งํ๋
์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํด์ฃผ์ธ์.
์๊ตฌ์ฌํญ:
1. ํน์ ํค์๋(์: 'AI ๊ธฐ์ ')๋ก ๊ฒ์๋ ๊ธฐ์ฌ ์ ๋ชฉ, ๋ณธ๋ฌธ, ์์ฑ์ผ์๋ฅผ ์ถ์ถ
2. ์ต์ ๊ธฐ์ฌ 20๊ฐ๋ฅผ ์์ง
3. ๊ฒฐ๊ณผ๋ฅผ CSV ํ์ผ๋ก ์ ์ฅ
4. robots.txt๋ฅผ ์ค์ํ๊ณ ์ ์ ํ ๋๋ ์ด(1์ด) ์ถ๊ฐ
5. ์๋ฌ ํธ๋ค๋ง ํฌํจ
์ถ๋ ฅ ํ์:
- ์ฃผ์์ด ํฌํจ๋ ์์ ํ Python ์ฝ๋
- ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น ๋ช
๋ น์ด
- ์ฌ์ฉ ์์
"""
# ๋ ํ๋กฌํํธ ๋น๊ต
comparison = evaluator.compare_prompts(bad_prompt, good_prompt)
print(f"์น์: {comparison['winner']}")
print(f"์ ์ ์ฐจ์ด: {comparison['score_difference']:.1f}์ ")
print(f"\nํ๋กฌํํธ 1 ์ ์: {comparison['prompt1']['score']}/10")
print(f"ํ๋กฌํํธ 2 ์ ์: {comparison['prompt2']['score']}/10")
์์ 3: ๋ฐฐ์น ํ๊ฐ๋ก ์ฌ๋ฌ ๋ฒ์ ํ ์คํธ
# ์ฌ๋ฌ ๋ฒ์ ์ ํ๋กฌํํธ ์ค๋น
prompts_to_test = [
"๋ฐ์ดํฐ ๋ถ์ ์ฝ๋ ์์ฑํด์ค",
"Python pandas๋ฅผ ์ฌ์ฉํด์ CSV ํ์ผ์ ๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ๋ ์ฝ๋๋ฅผ ์์ฑํด์ค",
"""
Python pandas๋ฅผ ์ฌ์ฉํ์ฌ sales_data.csv ํ์ผ์ ๋ถ์ํ๋ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํด์ฃผ์ธ์.
๋ฐ์ดํฐ ๊ตฌ์กฐ:
- ์ปฌ๋ผ: date, product, quantity, price
- ์ฝ 10,000๊ฐ ํ
๋ถ์ ๋ด์ฉ:
1. ์๋ณ ์ด ๋งค์ถ ๊ณ์ฐ
2. ๊ฐ์ฅ ๋ง์ด ํ๋ฆฐ ์์ 5๊ฐ ์ ํ
3. ๋งค์ถ ์ถ์ธ ์๊ฐํ (matplotlib ์ฌ์ฉ)
์ถ๋ ฅ:
- ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ์ฝ์์ ์ถ๋ ฅ
- ๊ทธ๋ํ๋ฅผ PNG ํ์ผ๋ก ์ ์ฅ
- ์ฝ๋์ ์ฃผ์ ํฌํจ
"""
]
# ์ผ๊ด ํ๊ฐ
results = evaluator.batch_evaluate(prompts_to_test)
# ๊ฒฐ๊ณผ ์ ๋ ฌ ๋ฐ ์ถ๋ ฅ
sorted_results = sorted(
enumerate(results, 1),
key=lambda x: x[1]['result'].get('total_score', 0) if x[1]['success'] else 0,
reverse=True
)
print("=== ํ๊ฐ ๊ฒฐ๊ณผ ์์ ===\n")
for rank, (idx, result) in enumerate(sorted_results, 1):
if result['success']:
score = result['result']['total_score']
grade = result['result']['grade']
print(f"{rank}์: ํ๋กฌํํธ #{idx} - {score:.1f}์ ({grade}๋ฑ๊ธ)")
else:
print(f"{rank}์: ํ๋กฌํํธ #{idx} - ํ๊ฐ ์คํจ")
๐ ๊ฒฐ๊ณผ ์๊ฐํ ๋ฐ ๋ฆฌํฌํธ ์์ฑ
ํ๊ฐ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ธฐ ์ข๊ฒ ์๊ฐํํ๋ฉด ํจ์ฌ ์ ์ฉํด! ๊ฐ๋จํ HTML ๋ฆฌํฌํธ๋ฅผ ์์ฑํ๋ ๊ธฐ๋ฅ์ ์ถ๊ฐํด๋ณด์.utils.py - ์ ํธ๋ฆฌํฐ ํจ์๋ค
import json
from datetime import datetime
def generate_html_report(evaluation_result, prompt_text, output_file='report.html'):
"""
ํ๊ฐ ๊ฒฐ๊ณผ๋ฅผ HTML ๋ฆฌํฌํธ๋ก ์์ฑ
Args:
evaluation_result (dict): ํ๊ฐ ๊ฒฐ๊ณผ
prompt_text (str): ํ๊ฐ๋ ํ๋กฌํํธ
output_file (str): ์ถ๋ ฅ ํ์ผ๋ช
"""
if not evaluation_result['success']:
print(f"๋ฆฌํฌํธ ์์ฑ ์คํจ: {evaluation_result.get('error')}")
return
result = evaluation_result['result']
scores = result.get('scores', {})
# ๋ ์ด๋ ์ฐจํธ์ฉ ๋ฐ์ดํฐ (Chart.js ์ฌ์ฉ)
criteria = list(scores.keys())
values = list(scores.values())
html_content = f"""
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ํ๋กฌํํธ ํ๊ฐ ๋ฆฌํฌํธ</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>.tx-header{background:linear-gradient(135deg,#f5f7fa 0%,#e8ecf1 100%);
border-radius:16px;
padding:40px 30px;
text-align:center;
margin-bottom:40px;
border:2px solid #d4dce5}
.tx-section{margin:50px 0;
padding:25px;
background:#fafbfc;
border-radius:12px;
border-left:4px solid #a8b8d8}
.tx-highlight{background:linear-gradient(120deg,#fef5e7 0%,#fdebd0 100%);
padding:20px;
border-radius:10px;
margin:25px 0;
border:1px solid #f0d9b5}
.tx-tip{background:#e8f4f8;
padding:18px;
border-radius:10px;
margin:25px 0;
border-left:4px solid #7eb8d1}
.tx-warning{background:#fff4e6;
padding:18px;
border-radius:10px;
margin:25px 0;
border-left:4px solid #f5a962}
.tx-step{background:#ffffff;
padding:20px;
margin:20px 0;
border-radius:10px;
border:2px solid #e0e5eb}
.tx-table-wrap{overflow-x:auto;
margin:25px 0}
.tx-table{width:100%;
border-collapse:collapse;
background:#ffffff;
border-radius:8px;
overflow:hidden}
.tx-table th{background:#e8ecf1;
padding:12px;
text-align:left;
font-weight:600;
border-bottom:2px solid #d4dce5}
.tx-table td{padding:12px;
border-bottom:1px solid #e8ecf1}
.tx-emphasis{color:#5a7ba8;
font-weight:600}
.tx-subtitle{color:#6b7c93;
font-size:1.1em;
margin:15px 0}</style>
</head>
<body>
<div class="header">
<h1>๐ฏ ํ๋กฌํํธ ํ๊ฐ ๋ฆฌํฌํธ</h1>
<p>์์ฑ ์๊ฐ: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</p>
</div>
<div class="score-card">
<h2>์ข
ํฉ ํ๊ฐ</h2>
<div style="display: flex; align-items: center; gap: 30px;">
<div class="grade">{result.get('grade', 'N/A')}</div>
<div>
<h3>์ด์ : {result.get('total_score', 0):.1f}/10</h3>
<p>ํ๊ฐ ๊ธฐ์ค 5๊ฐ ํญ๋ชฉ์ ํ๊ท ์ ์</p>
</div>
</div>
</div>
<div class="section">
<h2>๐ ํ๊ฐ๋ ํ๋กฌํํธ</h2>
<div class="prompt-box">{prompt_text}</div>
</div>
<div class="section">
<h2>๐ ์ธ๋ถ ์ ์</h2>
<canvas id="radarChart" width="400" height="400"></canvas>
</div>
<div class="section">
<h2>๐ช ๊ฐ์ </h2>
{''.join([f'<div class="suggestion">โ
{s}</div>' for s in result.get('strengths', [])])}
</div>
<div class="section">
<h2>โ ๏ธ ์ฝ์ </h2>
{''.join([f'<div class="suggestion">โ {w}</div>' for w in result.get('weaknesses', [])])}
</div>
<div class="section">
<h2>๐ก ๊ฐ์ ์ ์</h2>
{''.join([f'<div class="suggestion">๐ง {s}</div>' for s in result.get('suggestions', [])])}
</div>
<div class="section">
<h2>โจ ๊ฐ์ ๋ ๋ฒ์ </h2>
<div class="improved">{result.get('improved_version', '์ ๊ณต๋์ง ์์')}</div>
</div>
<script>
const ctx = document.getElementById('radarChart').getContext('2d');
const radarChart = new Chart(ctx, {{
type: 'radar',
data: {{
labels: {json.dumps([c.title() for c in criteria])},
datasets: [{{
label: '์ ์',
data: {json.dumps(values)},
backgroundColor: 'rgba(102, 126, 234, 0.2)',
borderColor: 'rgba(102, 126, 234, 1)',
borderWidth: 2,
pointBackgroundColor: 'rgba(102, 126, 234, 1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(102, 126, 234, 1)'
}}]
}},
options: {{
scales: {{
r: {{
beginAtZero: true,
max: 10,
ticks: {{
stepSize: 2
}}
}}
}},
plugins: {{
legend: {{
display: false
}}
}}
}}
}});
</script>
</body>
</html>
"""
with open(output_file, 'w', encoding='utf-8') as f:
f.write(html_content)
print(f"โ
๋ฆฌํฌํธ๊ฐ ์์ฑ๋์์ต๋๋ค: {output_file}")
def save_evaluation_log(evaluation_result, prompt_text, log_file='evaluation_log.json'):
"""
ํ๊ฐ ๊ฒฐ๊ณผ๋ฅผ JSON ๋ก๊ทธ๋ก ์ ์ฅ
Args:
evaluation_result (dict): ํ๊ฐ ๊ฒฐ๊ณผ
prompt_text (str): ํ๊ฐ๋ ํ๋กฌํํธ
log_file (str): ๋ก๊ทธ ํ์ผ๋ช
"""
log_entry = {
'timestamp': datetime.now().isoformat(),
'prompt': prompt_text,
'evaluation': evaluation_result
}
# ๊ธฐ์กด ๋ก๊ทธ ์ฝ๊ธฐ
try:
with open(log_file, 'r', encoding='utf-8') as f:
logs = json.load(f)
except FileNotFoundError:
logs = []
# ์ ๋ก๊ทธ ์ถ๊ฐ
logs.append(log_entry)
# ์ ์ฅ
with open(log_file, 'w', encoding='utf-8') as f:
json.dump(logs, f, ensure_ascii=False, indent=2)
print(f"โ
๋ก๊ทธ๊ฐ ์ ์ฅ๋์์ต๋๋ค: {log_file}")
def calculate_statistics(log_file='evaluation_log.json'):
"""
์ ์ฅ๋ ํ๊ฐ ๋ก๊ทธ์์ ํต๊ณ ๊ณ์ฐ
Args:
log_file (str): ๋ก๊ทธ ํ์ผ๋ช
Returns:
dict: ํต๊ณ ์ ๋ณด
"""
try:
with open(log_file, 'r', encoding='utf-8') as f:
logs = json.load(f)
except FileNotFoundError:
return {'error': '๋ก๊ทธ ํ์ผ์ด ์์ต๋๋ค'}
if not logs:
return {'error': 'ํ๊ฐ ๊ธฐ๋ก์ด ์์ต๋๋ค'}
total_scores = []
criteria_scores = {
'clarity': [],
'specificity': [],
'context': [],
'structure': [],
'constraints': []
}
for log in logs:
if log['evaluation']['success']:
result = log['evaluation']['result']
total_scores.append(result.get('total_score', 0))
for criterion, score in result.get('scores', {}).items():
if criterion in criteria_scores:
criteria_scores[criterion].append(score)
if not total_scores:
return {'error': '์ ํจํ ํ๊ฐ ๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค'}
# ํต๊ณ ๊ณ์ฐ
stats = {
'total_evaluations': len(logs),
'average_score': sum(total_scores) / len(total_scores),
'max_score': max(total_scores),
'min_score': min(total_scores),
'criteria_averages': {
criterion: sum(scores) / len(scores) if scores else 0
for criterion, scores in criteria_scores.items()
}
}
return stats
๋ฆฌํฌํธ ์์ฑ ์์
from evaluator import PromptEvaluator
from utils import generate_html_report, save_evaluation_log, calculate_statistics
# ํ๊ฐ ์คํ
evaluator = PromptEvaluator()
test_prompt = "Python์ผ๋ก ๋จธ์ ๋ฌ๋ ๋ชจ๋ธ์ ๋ง๋ค์ด์ค"
result = evaluator.evaluate(test_prompt)
# HTML ๋ฆฌํฌํธ ์์ฑ
generate_html_report(result, test_prompt, 'my_evaluation.html')
# JSON ๋ก๊ทธ ์ ์ฅ
save_evaluation_log(result, test_prompt)
# ํต๊ณ ํ์ธ
stats = calculate_statistics()
print("\n=== ํ๊ฐ ํต๊ณ ===")
print(f"์ด ํ๊ฐ ํ์: {stats['total_evaluations']}")
print(f"ํ๊ท ์ ์: {stats['average_score']:.2f}")
print(f"์ต๊ณ ์ ์: {stats['max_score']:.2f}")
print(f"์ต์ ์ ์: {stats['min_score']:.2f}")
๐ ๊ณ ๊ธ ๊ธฐ๋ฅ ์ถ๊ฐํ๊ธฐ
๊ธฐ๋ณธ ๊ธฐ๋ฅ์ ์์ฑํ์ผ๋, ์ด์ ๋ ์ค์ฉ์ ์ธ ๊ณ ๊ธ ๊ธฐ๋ฅ๋ค์ ์ถ๊ฐํด๋ณด์!1. ํ๋กฌํํธ ์๋ ๊ฐ์ ๊ธฐ๋ฅ
ํ๊ฐ๋ง ํ๋ ๊ฒ ์๋๋ผ, ์๋์ผ๋ก ๊ฐ์ ๋ ๋ฒ์ ์ ์์ฑํ๊ณ ๋ค์ ํ๊ฐํ๋ ๋ฐ๋ณต ํ๋ก์ธ์ค๋ฅผ ๊ตฌํํ ์ ์์ด.class PromptEvaluator:
# ... ๊ธฐ์กด ์ฝ๋ ...
def iterative_improvement(self, initial_prompt, max_iterations=3, target_score=8.0):
"""
ํ๋กฌํํธ๋ฅผ ๋ฐ๋ณต์ ์ผ๋ก ๊ฐ์
Args:
initial_prompt (str): ์ด๊ธฐ ํ๋กฌํํธ
max_iterations (int): ์ต๋ ๋ฐ๋ณต ํ์
target_score (float): ๋ชฉํ ์ ์
Returns:
dict: ๊ฐ์ ๊ณผ์ ๋ฐ ์ต์ข
๊ฒฐ๊ณผ
"""
current_prompt = initial_prompt
history = []
for iteration in range(max_iterations):
print(f"\n=== ๋ฐ๋ณต {iteration + 1}/{max_iterations} ===")
# ํ์ฌ ํ๋กฌํํธ ํ๊ฐ
result = self.evaluate(current_prompt)
if not result['success']:
break
current_score = result['result'].get('total_score', 0)
print(f"ํ์ฌ ์ ์: {current_score:.2f}/10")
# ๊ธฐ๋ก ์ ์ฅ
history.append({
'iteration': iteration + 1,
'prompt': current_prompt,
'score': current_score,
'evaluation': result['result']
})
# ๋ชฉํ ๋ฌ์ฑ ํ์ธ
if current_score >= target_score:
print(f"โ
๋ชฉํ ์ ์ ๋ฌ์ฑ! ({current_score:.2f} >= {target_score})")
break
# ๊ฐ์ ๋ ๋ฒ์ ์ผ๋ก ์
๋ฐ์ดํธ
improved = result['result'].get('improved_version')
if improved and improved != current_prompt:
current_prompt = improved
print("๐ ํ๋กฌํํธ ๊ฐ์ ์ค...")
else:
print("โ ๏ธ ๋ ์ด์ ๊ฐ์ ํ ์ ์์ต๋๋ค.")
break
return {
'initial_prompt': initial_prompt,
'final_prompt': current_prompt,
'initial_score': history[0]['score'] if history else 0,
'final_score': history[-1]['score'] if history else 0,
'improvement': history[-1]['score'] - history[0]['score'] if len(history) > 1 else 0,
'iterations': len(history),
'history': history
}
2. ํ๋กฌํํธ ํ ํ๋ฆฟ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
์์ฃผ ์ฌ์ฉํ๋ ํ๋กฌํํธ ํจํด์ ํ ํ๋ฆฟ์ผ๋ก ์ ์ฅํ๊ณ ๊ด๋ฆฌํ๋ ๊ธฐ๋ฅ์ด์ผ.class PromptTemplateLibrary:
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ ๊ด๋ฆฌ ํด๋์ค"""
def __init__(self, templates_file='templates.json'):
self.templates_file = templates_file
self.templates = self._load_templates()
def _load_templates(self):
"""ํ
ํ๋ฆฟ ํ์ผ ๋ก๋"""
try:
with open(self.templates_file, 'r', encoding='utf-8') as f:
return json.load(f)
except FileNotFoundError:
return {}
def save_template(self, name, prompt, category='general', tags=None):
"""
ํ
ํ๋ฆฟ ์ ์ฅ
Args:
name (str): ํ
ํ๋ฆฟ ์ด๋ฆ
prompt (str): ํ๋กฌํํธ ๋ด์ฉ
category (str): ์นดํ
๊ณ ๋ฆฌ
tags (list): ํ๊ทธ ๋ฆฌ์คํธ
"""
self.templates[name] = {
'prompt': prompt,
'category': category,
'tags': tags or [],
'created_at': datetime.now().isoformat()
}
with open(self.templates_file, 'w', encoding='utf-8') as f:
json.dump(self.templates, f, ensure_ascii=False, indent=2)
print(f"โ
ํ
ํ๋ฆฟ '{name}' ์ ์ฅ ์๋ฃ")
def get_template(self, name):
"""ํ
ํ๋ฆฟ ๊ฐ์ ธ์ค๊ธฐ"""
return self.templates.get(name)
def list_templates(self, category=None):
"""ํ
ํ๋ฆฟ ๋ชฉ๋ก ์กฐํ"""
if category:
return {
name: info for name, info in self.templates.items()
if info['category'] == category
}
return self.templates
def search_by_tag(self, tag):
"""ํ๊ทธ๋ก ํ
ํ๋ฆฟ ๊ฒ์"""
return {
name: info for name, info in self.templates.items()
if tag in info.get('tags', [])
}
# ์ฌ์ฉ ์์
library = PromptTemplateLibrary()
# ๊ณ ํ์ง ํ
ํ๋ฆฟ ์ ์ฅ
library.save_template(
name='code_generation_template',
prompt="""
[ํ๋ก๊ทธ๋๋ฐ ์ธ์ด]๋ฅผ ์ฌ์ฉํ์ฌ [์์
์ค๋ช
]์ ์ํํ๋ ์ฝ๋๋ฅผ ์์ฑํด์ฃผ์ธ์.
์๊ตฌ์ฌํญ:
1. [๊ตฌ์ฒด์ ์๊ตฌ์ฌํญ 1]
2. [๊ตฌ์ฒด์ ์๊ตฌ์ฌํญ 2]
3. [๊ตฌ์ฒด์ ์๊ตฌ์ฌํญ 3]
์ ์ฝ์กฐ๊ฑด:
- [์ ์ฝ์กฐ๊ฑด 1]
- [์ ์ฝ์กฐ๊ฑด 2]
์ถ๋ ฅ ํ์:
- ์ฃผ์์ด ํฌํจ๋ ์์ ํ ์ฝ๋
- ์ฌ์ฉ ์์
- ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ชฉ๋ก
""",
category='coding',
tags=['code', 'programming', 'template']
)
# ํ
ํ๋ฆฟ ์ฌ์ฉ
template = library.get_template('code_generation_template')
if template:
# ๋ณ์ ์นํ
actual_prompt = template['prompt'].replace(
'[ํ๋ก๊ทธ๋๋ฐ ์ธ์ด]', 'Python'
).replace(
'[์์
์ค๋ช
]', '์น ์คํฌ๋ํ'
)
# ... ๋๋จธ์ง ๋ณ์๋ค๋ ์นํ ...
3. ์ค์๊ฐ ๋ชจ๋ํฐ๋ง ๋์๋ณด๋
Flask๋ฅผ ์ฌ์ฉํด์ ๊ฐ๋จํ ์น ๋์๋ณด๋๋ฅผ ๋ง๋ค ์๋ ์์ด!from flask import Flask, render_template, request, jsonify
from evaluator import PromptEvaluator
app = Flask(__name__)
evaluator = PromptEvaluator()
@app.route('/')
def index():
return render_template('dashboard.html')
@app.route('/api/evaluate', methods=['POST'])
def api_evaluate():
"""ํ๋กฌํํธ ํ๊ฐ API ์๋ํฌ์ธํธ"""
data = request.json
prompt = data.get('prompt', '')
if not prompt:
return jsonify({'error': 'ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ์ธ์'}), 400
result = evaluator.evaluate(prompt)
return jsonify(result)
@app.route('/api/compare', methods=['POST'])
def api_compare():
"""ํ๋กฌํํธ ๋น๊ต API ์๋ํฌ์ธํธ"""
data = request.json
prompt1 = data.get('prompt1', '')
prompt2 = data.get('prompt2', '')
if not prompt1 or not prompt2:
return jsonify({'error': '๋ ๊ฐ์ ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ์ธ์'}), 400
result = evaluator.compare_prompts(prompt1, prompt2)
return jsonify(result)
if __name__ == '__main__':
app.run(debug=True, port=5000)
โก ์ฑ๋ฅ ์ต์ ํ ๋ฐ ๋น์ฉ ๊ด๋ฆฌ
Claude API๋ ํ ํฐ ๊ธฐ๋ฐ ๊ณผ๊ธ์ด๋ผ์, ํจ์จ์ ์ผ๋ก ์ฌ์ฉํ๋ ๊ฒ ์ค์ํด!1. ์บ์ฑ ์ ๋ต
๊ฐ์ ํ๋กฌํํธ๋ฅผ ๋ฐ๋ณต ํ๊ฐํ์ง ์๋๋ก ์บ์ฑ์ ๊ตฌํํ์.import hashlib
import pickle
from pathlib import Path
class CachedEvaluator(PromptEvaluator):
"""์บ์ฑ ๊ธฐ๋ฅ์ด ์ถ๊ฐ๋ ํ๊ฐ๊ธฐ"""
def __init__(self, api_key=None, cache_dir='cache'):
super().__init__(api_key)
self.cache_dir = Path(cache_dir)
self.cache_dir.mkdir(exist_ok=True)
def _get_cache_key(self, prompt_text):
"""ํ๋กฌํํธ์ ํด์ ํค ์์ฑ"""
return hashlib.md5(prompt_text.encode()).hexdigest()
def _get_cache_path(self, cache_key):
"""์บ์ ํ์ผ ๊ฒฝ๋ก"""
return self.cache_dir / f"{cache_key}.pkl"
def evaluate(self, prompt_text, use_cache=True, **kwargs):
"""
์บ์ฑ์ ์ง์ํ๋ ํ๊ฐ
Args:
prompt_text (str): ํ๊ฐํ ํ๋กฌํํธ
use_cache (bool): ์บ์ ์ฌ์ฉ ์ฌ๋ถ
"""
if use_cache:
cache_key = self._get_cache_key(prompt_text)
cache_path = self._get_cache_path(cache_key)
# ์บ์ ํ์ธ
if cache_path.exists():
print("๐ฆ ์บ์์์ ๊ฒฐ๊ณผ ๋ก๋")
with open(cache_path, 'rb') as f:
return pickle.load(f)
# ์ค์ ํ๊ฐ ์ํ
result = super().evaluate(prompt_text, **kwargs)
# ์บ์ ์ ์ฅ
if use_cache and result['success']:
cache_key = self._get_cache_key(prompt_text)
cache_path = self._get_cache_path(cache_key)
with open(cache_path, 'wb') as f:
pickle.dump(result, f)
return result
def clear_cache(self):
"""์บ์ ์ ์ฒด ์ญ์ """
for cache_file in self.cache_dir.glob('*.pkl'):
cache_file.unlink()
print("๐๏ธ ์บ์ ์ญ์ ์๋ฃ")
2. ๋ฐฐ์น ์ฒ๋ฆฌ ์ต์ ํ
์ฌ๋ฌ ํ๋กฌํํธ๋ฅผ ํ๊ฐํ ๋ ๋ณ๋ ฌ ์ฒ๋ฆฌ๋ก ์๋๋ฅผ ๋์ผ ์ ์์ด.from concurrent.futures import ThreadPoolExecutor, as_completed
class OptimizedEvaluator(CachedEvaluator):
"""์ต์ ํ๋ ํ๊ฐ๊ธฐ"""
def batch_evaluate_parallel(self, prompts_list, max_workers=3):
"""
๋ณ๋ ฌ ๋ฐฐ์น ํ๊ฐ
Args:
prompts_list (list): ํ๋กฌํํธ ๋ฆฌ์คํธ
max_workers (int): ๋์ ์คํ ์์ปค ์
"""
results = []
with ThreadPoolExecutor(max_workers=max_workers) as executor:
# ๋ชจ๋ ์์
์ ์ถ
future_to_prompt = {
executor.submit(self.evaluate, prompt): prompt
for prompt in prompts_list
}
# ์๋ฃ๋ ์์
์์ง
for future in as_completed(future_to_prompt):
prompt = future_to_prompt[future]
try:
result = future.result()
results.append(result)
print(f"โ
์๋ฃ: {len(results)}/{len(prompts_list)}")
except Exception as e:
print(f"โ ์ค๋ฅ ๋ฐ์: {e}")
results.append({'success': False, 'error': str(e)})
return results
3. ๋น์ฉ ์ถ์
API ์ฌ์ฉ๋๊ณผ ์์ ๋น์ฉ์ ์ถ์ ํ๋ ๊ธฐ๋ฅ์ด์ผ.class CostTracker:
"""API ๋น์ฉ ์ถ์ ํด๋์ค"""
# Claude 3 Sonnet ๊ฐ๊ฒฉ (2024๋
๊ธฐ์ค, ์ค์ ๊ฐ๊ฒฉ์ ํ์ธ ํ์)
PRICE_PER_1K_INPUT_TOKENS = 0.003 # $0.003 per 1K tokens
PRICE_PER_1K_OUTPUT_TOKENS = 0.015 # $0.015 per 1K tokens
def __init__(self):
self.total_input_tokens = 0
self.total_output_tokens = 0
self.request_count = 0
def add_usage(self, input_tokens, output_tokens):
"""์ฌ์ฉ๋ ์ถ๊ฐ"""
self.total_input_tokens += input_tokens
self.total_output_tokens += output_tokens
self.request_count += 1
def get_cost(self):
"""์์ ๋น์ฉ ๊ณ์ฐ"""
input_cost = (self.total_input_tokens / 1000) * self.PRICE_PER_1K_INPUT_TOKENS
output_cost = (self.total_output_tokens / 1000) * self.PRICE_PER_1K_OUTPUT_TOKENS
return {
'input_cost': input_cost,
'output_cost': output_cost,
'total_cost': input_cost + output_cost,
'total_tokens': self.total_input_tokens + self.total_output_tokens,
'request_count': self.request_count
}
def print_summary(self):
"""๋น์ฉ ์์ฝ ์ถ๋ ฅ"""
cost = self.get_cost()
print("\n=== ๐ฐ API ์ฌ์ฉ ๋น์ฉ ์์ฝ ===")
print(f"์ด ์์ฒญ ์: {cost['request_count']}")
print(f"์ด ํ ํฐ ์: {cost['total_tokens']:,}")
print(f" - ์
๋ ฅ: {self.total_input_tokens:,} tokens")
print(f" - ์ถ๋ ฅ: {self.total_output_tokens:,} tokens")
print(f"์์ ๋น์ฉ: ${cost['total_cost']:.4f}")
print(f" - ์
๋ ฅ ๋น์ฉ: ${cost['input_cost']:.4f}")
print(f" - ์ถ๋ ฅ ๋น์ฉ: ${cost['output_cost']:.4f}")
# ํ๊ฐ๊ธฐ์ ํตํฉ
class CostAwareEvaluator(OptimizedEvaluator):
"""๋น์ฉ ์ถ์ ๊ธฐ๋ฅ์ด ์๋ ํ๊ฐ๊ธฐ"""
def __init__(self, api_key=None, cache_dir='cache'):
super().__init__(api_key, cache_dir)
self.cost_tracker = CostTracker()
def evaluate(self, prompt_text, **kwargs):
"""๋น์ฉ ์ถ์ ๊ณผ ํจ๊ป ํ๊ฐ"""
result = super().evaluate(prompt_text, **kwargs)
# ์ฌ์ฉ๋ ๊ธฐ๋ก
if result['success'] and 'usage' in result:
usage = result['usage']
self.cost_tracker.add_usage(
usage['input_tokens'],
usage['output_tokens']
)
return result
def get_cost_summary(self):
"""๋น์ฉ ์์ฝ ๋ฐํ"""
return self.cost_tracker.get_cost()
def print_cost_summary(self):
"""๋น์ฉ ์์ฝ ์ถ๋ ฅ"""
self.cost_tracker.print_summary()
โข ํ๋ก๋์ ํ๊ฒฝ์์๋ ๋ฐ๋์ ์บ์ฑ์ ํ์ฉํ์
โข ๋ฐฐ์น ์์ ์ ์ ์์ ๋น์ฉ์ ๊ณ์ฐํด๋ณด๋ ์ต๊ด์ ๋ค์ด์
โข ๋ฌด๋ฃ ํฌ๋ ๋ง์ด ์์ง๋๋ฉด ์๋์ผ๋ก ๊ณผ๊ธ๋๋ ์ฃผ์!
๐ง ์ค์ ํ์ฉ ์๋๋ฆฌ์ค
์ด์ ์ค์ ์ ๋ฌด์์ ์ด๋ป๊ฒ ํ์ฉํ ์ ์๋์ง ๊ตฌ์ฒด์ ์ธ ์๋๋ฆฌ์ค๋ฅผ ์ดํด๋ณด์!์๋๋ฆฌ์ค 1: ํ๋กฌํํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ง ๊ด๋ฆฌ
ํ์ฌ์์ ์ฌ์ฉํ๋ ๋ชจ๋ ํ๋กฌํํธ์ ํ์ง์ ์ ๊ธฐ์ ์ผ๋ก ์ ๊ฒํ๋ ์์คํ ์ด์ผ.import os
from pathlib import Path
def audit_prompt_library(library_dir, output_report='audit_report.html'):
"""
ํ๋กฌํํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ์ฒด ๊ฐ์ฌ
Args:
library_dir (str): ํ๋กฌํํธ ํ์ผ๋ค์ด ์๋ ๋๋ ํ ๋ฆฌ
output_report (str): ๊ฐ์ฌ ๋ฆฌํฌํธ ํ์ผ๋ช
"""
evaluator = CostAwareEvaluator()
library_path = Path(library_dir)
# ๋ชจ๋ .txt ํ์ผ ์ฐพ๊ธฐ
prompt_files = list(library_path.glob('**/*.txt'))
print(f"๐ ์ด {len(prompt_files)}๊ฐ์ ํ๋กฌํํธ ํ์ผ ๋ฐ๊ฒฌ")
audit_results = []
for prompt_file in prompt_files:
print(f"\nํ๊ฐ ์ค: {prompt_file.name}")
# ํ๋กฌํํธ ์ฝ๊ธฐ
with open(prompt_file, 'r', encoding='utf-8') as f:
prompt_text = f.read()
# ํ๊ฐ
result = evaluator.evaluate(prompt_text)
if result['success']:
score = result['result']['total_score']
grade = result['result']['grade']
audit_results.append({
'file': prompt_file.name,
'path': str(prompt_file),
'score': score,
'grade': grade,
'needs_improvement': score < 7.0,
'evaluation': result['result']
})
print(f" ์ ์: {score:.1f}/10 ({grade})")
else:
print(f" โ ํ๊ฐ ์คํจ: {result.get('error')}")
# ๊ฒฐ๊ณผ ์ ๋ ฌ (๋ฎ์ ์ ์ ์ฐ์ )
audit_results.sort(key=lambda x: x['score'])
# ๋ฆฌํฌํธ ์์ฑ
generate_audit_report(audit_results, output_report)
# ๋น์ฉ ์์ฝ
evaluator.print_cost_summary()
# ๊ฐ์ ํ์ ํญ๋ชฉ ์ถ๋ ฅ
needs_improvement = [r for r in audit_results if r['needs_improvement']]
if needs_improvement:
print(f"\nโ ๏ธ ๊ฐ์ ์ด ํ์ํ ํ๋กฌํํธ: {len(needs_improvement)}๊ฐ")
for item in needs_improvement[:5]: # ์์ 5๊ฐ๋ง
print(f" โข {item['file']}: {item['score']:.1f}์ ")
return audit_results
def generate_audit_report(audit_results, output_file):
"""๊ฐ์ฌ ๋ฆฌํฌํธ HTML ์์ฑ"""
# ... HTML ์์ฑ ์ฝ๋ (์์ ๋ฆฌํฌํธ ์์ฑ ํจ์ ์ฐธ๊ณ ) ...
pass
# ์คํ
if __name__ == '__main__':
results = audit_prompt_library('prompts_library/', 'quality_audit.html')
์๋๋ฆฌ์ค 2: A/B ํ ์คํธ ์๋ํ
์ฌ๋ฌ ๋ฒ์ ์ ํ๋กฌํํธ๋ฅผ ์๋์ผ๋ก ํ ์คํธํ๊ณ ์ต์ ์ ๋ฒ์ ์ ์ฐพ๋ ์์คํ ์ด์ผ.def ab_test_prompts(variants, test_cases, evaluator=None):
"""
ํ๋กฌํํธ A/B ํ
์คํธ
Args:
variants (dict): {'A': prompt_a, 'B': prompt_b, ...}
test_cases (list): ํ
์คํธํ ์
๋ ฅ ์ผ์ด์ค๋ค
evaluator: ํ๊ฐ๊ธฐ ์ธ์คํด์ค
"""
if evaluator is None:
evaluator = CostAwareEvaluator()
results = {variant: [] for variant in variants}
print(f"๐งช A/B ํ
์คํธ ์์: {len(variants)}๊ฐ ๋ณํ, {len(test_cases)}๊ฐ ์ผ์ด์ค\n")
for variant_name, prompt_template in variants.items():
print(f"=== ๋ณํ {variant_name} ํ
์คํธ ์ค ===")
for i, test_case in enumerate(test_cases, 1):
# ํ
ํ๋ฆฟ์ ํ
์คํธ ์ผ์ด์ค ์ ์ฉ
actual_prompt = prompt_template.format(**test_case)
# ํ๊ฐ
result = evaluator.evaluate(actual_prompt)
if result['success']:
score = result['result']['total_score']
results[variant_name].append({
'test_case': i,
'score': score,
'evaluation': result['result']
})
print(f" ์ผ์ด์ค {i}: {score:.1f}์ ")
# ๋ณํ๋ณ ํ๊ท ์ ์
avg_score = sum(r['score'] for r in results[variant_name]) / len(results[variant_name])
print(f" ํ๊ท ์ ์: {avg_score:.2f}/10\n")
# ์น์ ๊ฒฐ์
average_scores = {
variant: sum(r['score'] for r in scores) / len(scores)
for variant, scores in results.items()
}
winner = max(average_scores, key=average_scores.get)
print("\n๐ ํ
์คํธ ๊ฒฐ๊ณผ")
print("=" * 50)
for variant, avg_score in sorted(average_scores.items(), key=lambda x: x[1], reverse=True):
status = "๐ ์น์" if variant == winner else ""
print(f"{variant}: {avg_score:.2f}์ {status}")
evaluator.print_cost_summary()
return {
'winner': winner,
'scores': average_scores,
'detailed_results': results
}
# ์ฌ์ฉ ์์
variants = {
'A': """
{language}๋ก {task}๋ฅผ ์ํํ๋ ์ฝ๋๋ฅผ ์์ฑํด์ฃผ์ธ์.
""",
'B': """
{language}๋ฅผ ์ฌ์ฉํ์ฌ {task}๋ฅผ ์ํํ๋ ์ฝ๋๋ฅผ ์์ฑํด์ฃผ์ธ์.
์๊ตฌ์ฌํญ:
- ๋ช
ํํ ์ฃผ์ ํฌํจ
- ์๋ฌ ํธ๋ค๋ง
- ์ฌ์ฉ ์์ ์ ๊ณต
""",
'C': """
๋น์ ์ ์๋ จ๋ {language} ๊ฐ๋ฐ์์
๋๋ค.
๋ค์ ์์
์ ์ํํ๋ ํ๋ก๋์
๋ ๋ฒจ์ ์ฝ๋๋ฅผ ์์ฑํด์ฃผ์ธ์:
{task}
์๊ตฌ์ฌํญ:
1. ํ์
ํํธ ์ฌ์ฉ
2. Docstring ํฌํจ
3. ๋จ์ ํ
์คํธ ์ฝ๋
4. ์๋ฌ ํธ๋ค๋ง
5. ๋ก๊น
์ถ๋ ฅ ํ์:
- ๋ฉ์ธ ์ฝ๋
- ํ
์คํธ ์ฝ๋
- ์ฌ์ฉ ์์
- README
"""
}
test_cases = [
{'language': 'Python', 'task': '์น ์คํฌ๋ํ'},
{'language': 'Python', 'task': 'CSV ํ์ผ ์ฒ๋ฆฌ'},
{'language': 'JavaScript', 'task': 'REST API ํด๋ผ์ด์ธํธ'}
]
results = ab_test_prompts(variants, test_cases)
์๋๋ฆฌ์ค 3: CI/CD ํ์ดํ๋ผ์ธ ํตํฉ
GitHub Actions๋ GitLab CI์์ ํ๋กฌํํธ ํ์ง์ ์๋์ผ๋ก ๊ฒ์ฌํ๋ ์ํฌํ๋ก์ฐ์ผ.# .github/workflows/prompt-quality-check.yml
name: Prompt Quality Check
on:
pull_request:
paths:
- 'prompts/**/*.txt'
- 'prompts/**/*.md'
jobs:
quality-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install anthropic python-dotenv
- name: Run quality check
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
python scripts/check_prompt_quality.py
- name: Comment PR
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('quality_report.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
});
# scripts/check_prompt_quality.py
import sys
from pathlib import Path
from evaluator import PromptEvaluator
def check_changed_prompts():
"""๋ณ๊ฒฝ๋ ํ๋กฌํํธ ํ์ผ๋ค์ ํ์ง ๊ฒ์ฌ"""
evaluator = PromptEvaluator()
# Git diff๋ก ๋ณ๊ฒฝ๋ ํ์ผ ์ฐพ๊ธฐ
import subprocess
result = subprocess.run(
['git', 'diff', '--name-only', 'origin/main', 'HEAD'],
capture_output=True,
text=True
)
changed_files = [
f for f in result.stdout.strip().split('\n')
if f.startswith('prompts/') and (f.endswith('.txt') or f.endswith('.md'))
]
if not changed_files:
print("๋ณ๊ฒฝ๋ ํ๋กฌํํธ ํ์ผ์ด ์์ต๋๋ค.")
return True
print(f"๊ฒ์ฌํ ํ์ผ: {len(changed_files)}๊ฐ\n")
all_passed = True
report_lines = ["# ํ๋กฌํํธ ํ์ง ๊ฒ์ฌ ๊ฒฐ๊ณผ\n"]
for file_path in changed_files:
with open(file_path, 'r', encoding='utf-8') as f:
prompt_text = f.read()
result = evaluator.evaluate(prompt_text)
if result['success']:
score = result['result']['total_score']
grade = result['result']['grade']
status = "โ
ํต๊ณผ" if score >= 7.0 else "โ ๊ฐ์ ํ์"
passed = score >= 7.0
report_lines.append(f"## {file_path}")
report_lines.append(f"**์ ์**: {score:.1f}/10 ({grade})")
report_lines.append(f"**์ํ**: {status}\n")
if not passed:
all_passed = False
report_lines.append("### ๊ฐ์ ์ ์")
for suggestion in result['result'].get('suggestions', []):
report_lines.append(f"- {suggestion}")
report_lines.append("")
else:
all_passed = False
report_lines.append(f"## {file_path}")
report_lines.append(f"โ ํ๊ฐ ์คํจ: {result.get('error')}\n")
# ๋ฆฌํฌํธ ์ ์ฅ
with open('quality_report.md', 'w', encoding='utf-8') as f:
f.write('\n'.join(report_lines))
return all_passed
if __name__ == '__main__':
passed = check_changed_prompts()
sys.exit(0 if passed else 1)
๐ ํ๋กฌํํธ ์์ง๋์ด๋ง ๋ฒ ์คํธ ํ๋ํฐ์ค
๋๊ตฌ๋ฅผ ๋ง๋ค์์ผ๋, ์ด์ ์ค์ ๋ก ์ข์ ํ๋กฌํํธ๋ฅผ ์์ฑํ๋ ๋ฐฉ๋ฒ๋ ์์์ผ๊ฒ ์ง?1. ๋ช ํํ ์ญํ ๋ถ์ฌ (Role Assignment)
AI์๊ฒ ๊ตฌ์ฒด์ ์ธ ์ญํ ์ ๋ถ์ฌํ๋ฉด ๋ ์ผ๊ด๋ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ด."์ฝ๋๋ฅผ ์์ฑํด์ค"
โ ์ข์ ์:
"๋น์ ์ 10๋ ๊ฒฝ๋ ฅ์ ์๋์ด Python ๊ฐ๋ฐ์์ ๋๋ค. ํด๋ฆฐ ์ฝ๋ ์์น์ ์ค์ํ๋ฉฐ, ํญ์ ํ ์คํธ ๊ฐ๋ฅํ ์ฝ๋๋ฅผ ์์ฑํฉ๋๋ค."
2. ๋จ๊ณ๋ณ ์ง์ (Step-by-Step Instructions)
๋ณต์กํ ์์ ์ ๋จ๊ณ๋ณ๋ก ๋๋ ์ ์ง์ํ์."""
๋ค์ ๋จ๊ณ๋ก ์์ ์ ์ํํด์ฃผ์ธ์:
1. ๋จผ์ ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ๊ณ ๊ธฐ๋ณธ ํต๊ณ๋ฅผ ํ์ธ
2. ๊ฒฐ์ธก์น์ ์ด์์น๋ฅผ ์ฒ๋ฆฌ
3. ํน์ฑ ์์ง๋์ด๋ง ์ํ
4. ๋ชจ๋ธ ํ์ต ๋ฐ ํ๊ฐ
5. ๊ฒฐ๊ณผ๋ฅผ ์๊ฐํ
๊ฐ ๋จ๊ณ๋ง๋ค ์ฝ๋์ ์ค๋ช ์ ์ ๊ณตํด์ฃผ์ธ์.
"""
3. ์์ ์ ๊ณต (Few-Shot Learning)
์ํ๋ ์ถ๋ ฅ ํ์์ ์์๋ฅผ ๋ณด์ฌ์ฃผ๋ฉด ํจ์ฌ ์ ํํด์ ธ."""
๋ค์ ํ์์ผ๋ก ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์:
์์:
```python
def calculate_average(numbers: List[float]) -> float:
"""
์ซ์ ๋ฆฌ์คํธ์ ํ๊ท ์ ๊ณ์ฐํฉ๋๋ค.
Args:
numbers: ํ๊ท ์ ๊ณ์ฐํ ์ซ์ ๋ฆฌ์คํธ
Returns:
float: ํ๊ท ๊ฐ
Raises:
ValueError: ๋น ๋ฆฌ์คํธ๊ฐ ์ ๋ ฅ๋ ๊ฒฝ์ฐ
"""
if not numbers:
raise ValueError("๋น ๋ฆฌ์คํธ์ ๋๋ค")
return sum(numbers) / len(numbers)
```
์ด์ ์ค์๊ฐ์ ๊ณ์ฐํ๋ ํจ์๋ฅผ ๊ฐ์ ํ์์ผ๋ก ์์ฑํด์ฃผ์ธ์.
"""
4. ์ ์ฝ์กฐ๊ฑด ๋ช ์ (Constraints)
ํ์ง ๋ง์์ผ ํ ๊ฒ, ์ง์ผ์ผ ํ ๊ท์น์ ๋ช ํํ ํ์."""
์ ์ฝ์กฐ๊ฑด:
- ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ ๊ธ์ง (ํ์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ง ์ฌ์ฉ)
- ํจ์ ๊ธธ์ด๋ 20์ค ์ด๋ด
- ์ ์ญ ๋ณ์ ์ฌ์ฉ ๊ธ์ง
- ๋ชจ๋ ํจ์์ ํ์ ํํธ ํ์
"""
5. ์ถ๋ ฅ ํ์ ์ง์ (Output Format)
์ํ๋ ์ถ๋ ฅ ํ์์ ๊ตฌ์ฒด์ ์ผ๋ก ๋ช ์ํ์."""
์ถ๋ ฅ ํ์:
```json
{
"code": "์ค์ ์ฝ๋",
"explanation": "์ฝ๋ ์ค๋ช ",
"test_cases": [
{"input": "...", "expected": "..."},
{"input": "...", "expected": "..."}
],
"complexity": {
"time": "O(n)",
"space": "O(1)"
}
}
```
"""
โ๏ธ ์์ ์ด ๊ตฌ์ฒด์ ์ผ๋ก ์ค๋ช ๋์ด ์๋๊ฐ?
โ๏ธ ํ์ํ ๋งฅ๋ฝ ์ ๋ณด๊ฐ ์ ๊ณต๋์๋๊ฐ?
โ๏ธ ๋จ๊ณ๋ณ๋ก ๊ตฌ์กฐํ๋์ด ์๋๊ฐ?
โ๏ธ ์์๊ฐ ํฌํจ๋์ด ์๋๊ฐ?
โ๏ธ ์ ์ฝ์กฐ๊ฑด์ด ๋ช ์๋์ด ์๋๊ฐ?
โ๏ธ ์ถ๋ ฅ ํ์์ด ์ง์ ๋์ด ์๋๊ฐ?
โ๏ธ ๊ธ์ง ์ฌํญ์ด ๋ช ํํ๊ฐ?
๐ ํธ๋ฌ๋ธ์ํ ๊ฐ์ด๋
๊ฐ๋ฐํ๋ค ๋ณด๋ฉด ์ฌ๋ฌ ๋ฌธ์ ๋ฅผ ๋ง๋๊ฒ ๋ผ. ์์ฃผ ๋ฐ์ํ๋ ์ด์๋ค๊ณผ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ ๋ฆฌํ์ด!๋ฌธ์ 1: API ํค ์ธ์ฆ ์คํจ
AuthenticationError: Invalid API keyํด๊ฒฐ ๋ฐฉ๋ฒ:
1. .env ํ์ผ์ API ํค๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์ ๋ ฅ๋์๋์ง ํ์ธ
2. API ํค ์๋ค์ ๊ณต๋ฐฑ์ด ์๋์ง ํ์ธ
3. Anthropic ์ฝ์์์ API ํค๊ฐ ํ์ฑํ๋์ด ์๋์ง ํ์ธ
4. ํ๊ฒฝ ๋ณ์๊ฐ ์ ๋๋ก ๋ก๋๋๋์ง ํ์ธ:
import os
from dotenv import load_dotenv
load_dotenv()
print(f"API Key loaded: {bool(os.getenv('ANTHROPIC_API_KEY'))}")
๋ฌธ์ 2: JSON ํ์ฑ ์คํจ
Claude์ ์๋ต์์ JSON์ ์ถ์ถํ ์ ์์
ํด๊ฒฐ ๋ฐฉ๋ฒ:
1. ํ๋กฌํํธ์์ JSON ํ์์ ๋ ๋ช ํํ ์ง์
2. "๋ฐ๋์ ์ ํจํ JSON๋ง ์ถ๋ ฅํ์ธ์"๋ผ๊ณ ๊ฐ์กฐ
3. ํ์ฑ ๋ก์ง ๊ฐ์ :
def robust_json_parse(text):
"""๋ ๊ฒฌ๊ณ ํ JSON ํ์ฑ"""
import re
import json
# ์ฌ๋ฌ ํจํด ์๋
patterns = [
r'```json\s*(.*?)\s*```', # ```json ... ``` ๋ธ๋ก
r'```\s*(.*?)\s*```', # ``` ... ``` ๋ธ๋ก
r'\{[\s\S]*\}' # ์ค๊ดํธ๋ก ๋๋ฌ์ธ์ธ ๋ชจ๋ ๊ฒ
]
for pattern in patterns:
matches = re.findall(pattern, text, re.DOTALL)
for match in matches:
try:
return json.loads(match)
except:
continue
# ๋ชจ๋ ์๋ ์คํจ
raise ValueError("JSON์ ์ฐพ์ ์ ์์ต๋๋ค")
๋ฌธ์ 3: ํ ํฐ ์ ํ ์ด๊ณผ
Error: maximum context length exceededํด๊ฒฐ ๋ฐฉ๋ฒ:
1. ํ๋กฌํํธ ๊ธธ์ด ํ์ธ ๋ฐ ์ถ์
2. max_tokens ๊ฐ ์กฐ์
3. ๊ธด ํ๋กฌํํธ๋ ์์ฝํ๊ฑฐ๋ ๋ถํ :
def truncate_prompt(prompt, max_length=4000):
"""ํ๋กฌํํธ๋ฅผ ์์ ํ ๊ธธ์ด๋ก ์๋ฅด๊ธฐ"""
if len(prompt) <= max_length:
return prompt
# ์ค์ํ ๋ถ๋ถ๋ง ์ ์ง
parts = prompt.split('\n\n')
truncated = []
current_length = 0
for part in parts:
if current_length + len(part) > max_length:
break
truncated.append(part)
current_length += len(part)
return '\n\n'.join(truncated) + "\n\n[... ์๋ต ...]"
๋ฌธ์ 4: ํ๊ฐ ๊ฒฐ๊ณผ๊ฐ ์ผ๊ด๋์ง ์์
๊ฐ์ ํ๋กฌํํธ๋ฅผ ํ๊ฐํด๋ ๋งค๋ฒ ๋ค๋ฅธ ์ ์๊ฐ ๋์ด
ํด๊ฒฐ ๋ฐฉ๋ฒ:
1. temperature ํ๋ผ๋ฏธํฐ๋ฅผ ๋ฎ์ถฐ์ ์ผ๊ด์ฑ ํฅ์:
response = self.client.messages.create(
model=self.model,
max_tokens=self.max_tokens,
temperature=0.1, # ๋ฎ์ ๊ฐ = ๋ ์ผ๊ด์
messages=[...]
)
2. ์ฌ๋ฌ ๋ฒ ํ๊ฐํ๊ณ ํ๊ท ์ฌ์ฉ:
def stable_evaluate(self, prompt, num_runs=3):
"""์ฌ๋ฌ ๋ฒ ํ๊ฐํ๊ณ ํ๊ท ์ ์ ๋ฐํ"""
scores = []
for i in range(num_runs):
result = self.evaluate(prompt)
if result['success']:
scores.append(result['result']['total_score'])
return {
'average_score': sum(scores) / len(scores),
'std_dev': statistics.stdev(scores) if len(scores) > 1 else 0,
'all_scores': scores
}
๋ฌธ์ 5: ์๋๊ฐ ๋๋ฌด ๋๋ฆผ
๋ฐฐ์น ํ๊ฐ ์ ์๊ฐ์ด ๋๋ฌด ์ค๋ ๊ฑธ๋ฆผ
ํด๊ฒฐ ๋ฐฉ๋ฒ:
1. ์บ์ฑ ํ์ฉ (์์์ ๊ตฌํํ CachedEvaluator ์ฌ์ฉ)
2. ๋ณ๋ ฌ ์ฒ๋ฆฌ ์ฌ์ฉ
3. Quick mode ํ์ฉ (๊ฐ๋จํ ์ ์๋ง ํ์ํ ๊ฒฝ์ฐ)
4. API ํธ์ถ ์ต์ํ:
# ์ฌ๋ฌ ํ๋กฌํํธ๋ฅผ ํ๋์ ์์ฒญ์ผ๋ก ํ๊ฐ
def batch_evaluate_single_call(self, prompts_list):
"""ํ๋์ API ํธ์ถ๋ก ์ฌ๋ฌ ํ๋กฌํํธ ํ๊ฐ"""
combined_prompt = f"""
๋ค์ {len(prompts_list)}๊ฐ์ ํ๋กฌํํธ๋ฅผ ๊ฐ๊ฐ ํ๊ฐํด์ฃผ์ธ์.
๊ฐ ํ๋กฌํํธ๋ง๋ค 0-10์ ์ ์๋ฅผ JSON ๋ฐฐ์ด๋ก ๋ฐํํ์ธ์.
"""
for i, prompt in enumerate(prompts_list, 1):
combined_prompt += f"\nํ๋กฌํํธ {i}:\n{prompt}\n"
combined_prompt += """
์ถ๋ ฅ ํ์:
[
{"id": 1, "score": X.X},
{"id": 2, "score": X.X},
...
]
"""
# ํ๋์ API ํธ์ถ๋ก ์ฒ๋ฆฌ
result = self.evaluate(combined_prompt)
# ... ๊ฒฐ๊ณผ ํ์ฑ ...
๐ ํ๋ก์ ํธ ํ์ฅ ์์ด๋์ด
๊ธฐ๋ณธ ๋๊ตฌ๋ ์์ฑํ์ด! ์ด์ ๋ ๋ฐ์ ์ํฌ ์ ์๋ ์์ด๋์ด๋ค์ ์๊ฐํ ๊ฒ.1. ๋ค๊ตญ์ด ์ง์
์์ด๋ฟ๋ง ์๋๋ผ ํ๊ตญ์ด, ์ผ๋ณธ์ด ๋ฑ ๋ค์ํ ์ธ์ด์ ํ๋กฌํํธ๋ฅผ ํ๊ฐํ ์ ์๊ฒ ํ์ฅํ์.EVALUATION_PROMPTS = {
'ko': """๋น์ ์ ํ๊ตญ์ด ํ๋กฌํํธ ํ๊ฐ ์ ๋ฌธ๊ฐ์
๋๋ค...""",
'en': """You are an expert in evaluating English prompts...""",
'ja': """ใใชใใฏๆฅๆฌ่ชใใญใณใใ่ฉไพกใฎๅฐ้ๅฎถใงใ..."""
}
def evaluate(self, prompt_text, language='ko'):
template = EVALUATION_PROMPTS.get(language, EVALUATION_PROMPTS['en'])
# ...
2. ๋๋ฉ์ธ๋ณ ํนํ ํ๊ฐ
์ฝ๋ฉ, ๊ธ์ฐ๊ธฐ, ์ด๋ฏธ์ง ์์ฑ ๋ฑ ๋๋ฉ์ธ๋ณ๋ก ๋ค๋ฅธ ํ๊ฐ ๊ธฐ์ค์ ์ ์ฉํ์.DOMAIN_CRITERIA = {
'coding': {
'clarity': 10,
'specificity': 15, # ์ฝ๋ฉ์ ๊ตฌ์ฒด์ฑ์ด ๋ ์ค์
'context': 10,
'structure': 10,
'constraints': 15
},
'writing': {
'clarity': 15,
'specificity': 10,
'context': 15, # ๊ธ์ฐ๊ธฐ๋ ๋งฅ๋ฝ์ด ์ค์
'structure': 10,
'constraints': 10
}
}
3. ํ๋กฌํํธ ๋ฒ์ ๊ด๋ฆฌ
Git์ฒ๋ผ ํ๋กฌํํธ์ ๋ณ๊ฒฝ ์ด๋ ฅ์ ์ถ์ ํ๊ณ ๊ด๋ฆฌํ๋ ์์คํ ์ด์ผ.class PromptVersionControl:
"""ํ๋กฌํํธ ๋ฒ์ ๊ด๋ฆฌ ์์คํ
"""
def __init__(self, repo_path='prompt_repo'):
self.repo_path = Path(repo_path)
self.repo_path.mkdir(exist_ok=True)
self.history_file = self.repo_path / 'history.json'
self.load_history()
def commit(self, prompt_id, prompt_text, message, evaluation=None):
"""์ ๋ฒ์ ์ปค๋ฐ"""
version = {
'version': len(self.history.get(prompt_id, [])) + 1,
'timestamp': datetime.now().isoformat(),
'prompt': prompt_text,
'message': message,
'evaluation': evaluation
}
if prompt_id not in self.history:
self.history[prompt_id] = []
self.history[prompt_id].append(version)
self.save_history()
def diff(self, prompt_id, version1, version2):
"""๋ ๋ฒ์ ๋น๊ต"""
# difflib ์ฌ์ฉํ์ฌ ์ฐจ์ด์ ํ์
import difflib
v1 = self.get_version(prompt_id, version1)
v2 = self.get_version(prompt_id, version2)
diff = difflib.unified_diff(
v1['prompt'].splitlines(),
v2['prompt'].splitlines(),
lineterm=''
)
return '\n'.join(diff)
4. ํ ํ์ ๊ธฐ๋ฅ
์ฌ๋ฌ ์ฌ๋์ด ํจ๊ป ํ๋กฌํํธ๋ฅผ ๊ฐ์ ํ๊ณ ๋ฆฌ๋ทฐํ ์ ์๋ ๊ธฐ๋ฅ์ด์ผ.class PromptReviewSystem:
"""ํ๋กฌํํธ ๋ฆฌ๋ทฐ ์์คํ
"""
def create_review_request(self, prompt_id, prompt_text, author):
"""๋ฆฌ๋ทฐ ์์ฒญ ์์ฑ"""
review_request = {
'id': str(uuid.uuid4()),
'prompt_id': prompt_id,
'prompt': prompt_text,
'author': author,
'created_at': datetime.now().isoformat(),
'status': 'pending',
'reviews': []
}
# ์ ์ฅ ๋ก์ง...
def add_review(self, request_id, reviewer, score, comments):
"""๋ฆฌ๋ทฐ ์ถ๊ฐ"""
review = {
'reviewer': reviewer,
'score': score,
'comments': comments,
'timestamp': datetime.now().isoformat()
}
# ์ ์ฅ ๋ก์ง...
def approve(self, request_id):
"""๋ฆฌ๋ทฐ ์น์ธ"""
# ๋ชจ๋ ๋ฆฌ๋ทฐ์ด๊ฐ ์น์ธํ๋์ง ํ์ธ
# ์น์ธ ์ ๋ฉ์ธ ๋ธ๋์น์ ๋จธ์ง
5. ํ๋กฌํํธ ๋ง์ผํ๋ ์ด์ค
๊ฒ์ฆ๋ ๊ณ ํ์ง ํ๋กฌํํธ๋ฅผ ๊ณต์ ํ๊ณ ๊ฑฐ๋ํ๋ ํ๋ซํผ์ด์ผ. ์ฌ๋ฅ๋ท ๊ฐ์ ๊ณณ์์ ์ด๋ฐ ์๋น์ค๋ฅผ ์ ๊ณตํ๋ฉด ์ ๋ง ์ ์ฉํ ๊ฑฐ์ผ! ๐กclass PromptMarketplace:
"""ํ๋กฌํํธ ๋ง์ผํ๋ ์ด์ค"""
def publish_prompt(self, prompt_text, metadata):
"""ํ๋กฌํํธ ๊ฒ์"""
# ํ์ง ๊ฒ์ฆ
evaluation = self.evaluator.evaluate(prompt_text)
if evaluation['result']['total_score'] < 8.0:
return {
'success': False,
'message': 'ํ์ง ๊ธฐ์ค(8.0์ )์ ์ถฉ์กฑํ์ง ๋ชปํ์ต๋๋ค'
}
listing = {
'id': str(uuid.uuid4()),
'prompt': prompt_text,
'category': metadata['category'],
'tags': metadata['tags'],
'price': metadata['price'],
'quality_score': evaluation['result']['total_score'],
'author': metadata['author'],
'published_at': datetime.now().isoformat()
}
# ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์ฅ...
return {'success': True, 'listing_id': listing['id']}
def search(self, query, category=None, min_score=7.0):
"""ํ๋กฌํํธ ๊ฒ์"""
# ๊ฒ์ ๋ก์ง...
pass
๐ ํ์ต ๋ฆฌ์์ค ๋ฐ ์ฐธ๊ณ ์๋ฃ
๋ ๊น์ด ๊ณต๋ถํ๊ณ ์ถ๋ค๋ฉด ์ด๋ฐ ์๋ฃ๋ค์ ์ถ์ฒํด!๊ณต์ ๋ฌธ์
โข Anthropic Claude API ๋ฌธ์: https://docs.anthropic.com/โข OpenAI Prompt Engineering Guide: ํ๋กฌํํธ ์์ฑ ๊ธฐ๋ฒ
โข Python asyncio ๋ฌธ์: ๋น๋๊ธฐ ์ฒ๋ฆฌ ์ต์ ํ
์ถ์ฒ ๋์
โข "The Art of Prompt Engineering" - ํ๋กฌํํธ ์์ง๋์ด๋ง ๊ธฐ์ดโข "Building LLM Applications" - LLM ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ
โข "Clean Code" - ์ฝ๋ ํ์ง ๊ด๋ฆฌ (ํ๋กฌํํธ์๋ ์ ์ฉ ๊ฐ๋ฅ!)
์จ๋ผ์ธ ์ปค๋ฎค๋ํฐ
โข Reddit r/PromptEngineering - ํ๋กฌํํธ ์์ง๋์ด๋ง ์ปค๋ฎค๋ํฐโข Discord: AI Developers - AI ๊ฐ๋ฐ์ ๋ชจ์
โข GitHub: awesome-prompt-engineering - ํ๋ ์ด์ ๋ ๋ฆฌ์์ค ๋ชจ์
์ค์ต ํ๋ก์ ํธ ์์ด๋์ด
1. ํ๋กฌํํธ ํ ํ๋ฆฟ ์์ฑ๊ธฐ - ๋๋ฉ์ธ๋ณ ์ต์ ํ๋ ํ ํ๋ฆฟ ์๋ ์์ฑ2. ํ๋กฌํํธ A/B ํ ์คํธ ํ๋ซํผ - ์น ๊ธฐ๋ฐ ํ ์คํธ ๋๊ตฌ
3. ํ๋กฌํํธ ํ์ง ๋์๋ณด๋ - ์ค์๊ฐ ๋ชจ๋ํฐ๋ง ์์คํ
4. ํ๋กฌํํธ ์ต์ ํ ๋ด - Slack/Discord ๋ด์ผ๋ก ์ฆ์ ํ๊ฐ
5. ํ๋กฌํํธ ํ์ต ํ๋ซํผ - ์ธํฐ๋ํฐ๋ธ ํํ ๋ฆฌ์ผ
โข ๋ค๋ฅธ ์ฌ๋์ ํ๋กฌํํธ๋ฅผ ๋ถ์ํ๊ณ ๊ฐ์ ์ ์ ์ฐพ์๋ณด์
โข ์์ ๋ง์ ํ๋กฌํํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ตฌ์ถํ์
โข ์ปค๋ฎค๋ํฐ์์ ํผ๋๋ฐฑ์ ์ฃผ๊ณ ๋ฐ์
โข ์ค์ ํ๋ก์ ํธ์ ์ ์ฉํ๋ฉด์ ๋ฐฐ์ฐ์!
๐ฌ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์! ์ฌ๊ธฐ๊น์ง ์ ๋ง ๊ธด ์ฌ์ ์ด์์ด. ์ฐ๋ฆฌ๋ Python๊ณผ Claude API๋ฅผ ํ์ฉํด์ ํ๋กฌํํธ ํ๊ฐ ๋๊ตฌ๋ฅผ ์ฒ์๋ถํฐ ๋๊น์ง ๋ง๋ค์ด๋ดค์ด. ๐์ฐ๋ฆฌ๊ฐ ๋ฐฐ์ด ๊ฒ๋ค
โ Claude API์ ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ๊ณผ ์ธ์ฆโ ํ๋กฌํํธ ํ์ง ํ๊ฐ์ 5๊ฐ์ง ํต์ฌ ์งํ
โ ํ๊ฐ ์์ง์ ์ค๊ณ์ ๊ตฌํ
โ ๊ฒฐ๊ณผ ์๊ฐํ ๋ฐ ๋ฆฌํฌํธ ์์ฑ
โ ์ฑ๋ฅ ์ต์ ํ์ ๋น์ฉ ๊ด๋ฆฌ
โ ์ค์ ํ์ฉ ์๋๋ฆฌ์ค์ ํธ๋ฌ๋ธ์ํ
โ ํ๋กฌํํธ ์์ง๋์ด๋ง ๋ฒ ์คํธ ํ๋ํฐ์ค
๋ค์ ๋จ๊ณ
์ด์ ์ด ๋๊ตฌ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์์ ๋ง์ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์ด๋ณด์!โข ์์ ์ ํ๋กฌํํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ตฌ์ถ ๋ฐ ๊ด๋ฆฌ
โข ์ผ์ผ ํ๋กฌํํธ ํ์ง ์ฒดํฌ ๋ฃจํด ๋ง๋ค๊ธฐ
2. ํ ํ๋ก์ ํธ
โข CI/CD ํ์ดํ๋ผ์ธ์ ํ์ง ๊ฒ์ฌ ํตํฉ
โข ํ ํ๋กฌํํธ ์คํ์ผ ๊ฐ์ด๋ ์๋ ๊ฒ์ฆ
3. ๋น์ฆ๋์ค
โข ํ๋กฌํํธ ์ปจ์คํ ์๋น์ค ์ ๊ณต
โข ํ๋กฌํํธ ํ์ง ์ธ์ฆ ์๋น์ค
โข ํ๋กฌํํธ ๋ง์ผํ๋ ์ด์ค ์ด์
๋ง์ง๋ง ์กฐ์ธ
ํ๋กฌํํธ ์์ง๋์ด๋ง์ ๊ณ์ ๋ฐ์ ํ๋ ๋ถ์ผ์ผ. ์ค๋ ๋ฐฐ์ด ๋ด์ฉ์ด ๋ด์ผ์ ๋ฌ๋ผ์ง ์ ์์ด. ํ์ง๋ง ํต์ฌ ์์น์ ๋ณํ์ง ์์:๋ช ํํ๊ฒ, ๊ตฌ์ฒด์ ์ผ๋ก, ๋งฅ๋ฝ๊ณผ ํจ๊ป, ๊ตฌ์กฐํํด์, ์ ์ฝ์กฐ๊ฑด์ ๋ช ์ํ๋ผ!
์ด ๋๊ตฌ๋ฅผ ๋ง๋ค๋ฉด์ ๋ฐฐ์ด ๊ฒ๋ค์ ์ค์ ํ๋ก์ ํธ์ ์ ์ฉํด๋ณด๊ณ , ๊ณ์ ๊ฐ์ ํด๋๊ฐ์. ๊ทธ๋ฆฌ๊ณ ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ ์์ ์ ์ ๋ฌธ์ฑ์ ๊ณต์ ํ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ผ! ๐ช
โ๏ธ ๋จ์ ํ ์คํธ๋ฅผ ์์ฑํ๋๊ฐ?
โ๏ธ ์๋ฌ ํธ๋ค๋ง์ด ์ถฉ๋ถํ๊ฐ?
โ๏ธ ๋ณด์ ์ค์ (API ํค ๊ด๋ฆฌ)์ด ์ฌ๋ฐ๋ฅธ๊ฐ?
โ๏ธ ์ฑ๋ฅ ์ต์ ํ๋ฅผ ๊ณ ๋ คํ๋๊ฐ?
โ๏ธ ์ฌ์ฉ์ ๋ฌธ์๋ฅผ ์์ฑํ๋๊ฐ?
โ๏ธ ์ค์ ํ๋ก์ ํธ์ ์ ์ฉํด๋ดค๋๊ฐ?
Happy Coding! ์ฆ๊ฑฐ์ด ํ๋กฌํํธ ์์ง๋์ด๋ง ๋๊ธธ! ๐
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.