fix(blog-lab): AI 생성 콘텐츠에 현재 날짜 컨텍스트 추가
Claude API 호출 시 시스템 프롬프트에 현재 날짜를 포함하여 2024년이 아닌 실제 날짜 기준으로 콘텐츠가 생성되도록 수정. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import date
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
import anthropic
|
import anthropic
|
||||||
@@ -22,11 +23,13 @@ def _get_client() -> anthropic.Anthropic:
|
|||||||
|
|
||||||
|
|
||||||
def _call_claude(prompt: str, max_tokens: int = 4096) -> str:
|
def _call_claude(prompt: str, max_tokens: int = 4096) -> str:
|
||||||
"""Claude API 호출. 단일 user 메시지."""
|
"""Claude API 호출. 단일 user 메시지. 현재 날짜 시스템 프롬프트 포함."""
|
||||||
client = _get_client()
|
client = _get_client()
|
||||||
|
today = date.today().isoformat()
|
||||||
resp = client.messages.create(
|
resp = client.messages.create(
|
||||||
model=CLAUDE_MODEL,
|
model=CLAUDE_MODEL,
|
||||||
max_tokens=max_tokens,
|
max_tokens=max_tokens,
|
||||||
|
system=f"현재 날짜는 {today}입니다. 모든 콘텐츠는 이 날짜 기준으로 작성하세요.",
|
||||||
messages=[{"role": "user", "content": prompt}],
|
messages=[{"role": "user", "content": prompt}],
|
||||||
)
|
)
|
||||||
return resp.content[0].text
|
return resp.content[0].text
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import date
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import anthropic
|
import anthropic
|
||||||
@@ -23,9 +24,11 @@ def _get_client() -> anthropic.Anthropic:
|
|||||||
|
|
||||||
def _call_claude(prompt: str, max_tokens: int = 8192) -> str:
|
def _call_claude(prompt: str, max_tokens: int = 8192) -> str:
|
||||||
client = _get_client()
|
client = _get_client()
|
||||||
|
today = date.today().isoformat()
|
||||||
resp = client.messages.create(
|
resp = client.messages.create(
|
||||||
model=CLAUDE_MODEL,
|
model=CLAUDE_MODEL,
|
||||||
max_tokens=max_tokens,
|
max_tokens=max_tokens,
|
||||||
|
system=f"현재 날짜는 {today}입니다. 모든 콘텐츠는 이 날짜 기준으로 작성하세요.",
|
||||||
messages=[{"role": "user", "content": prompt}],
|
messages=[{"role": "user", "content": prompt}],
|
||||||
)
|
)
|
||||||
return resp.content[0].text
|
return resp.content[0].text
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import date
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
import anthropic
|
import anthropic
|
||||||
@@ -44,9 +45,11 @@ def review_post(title: str, body: str) -> Dict[str, Any]:
|
|||||||
prompt = template.format(title=title, body=body[:6000])
|
prompt = template.format(title=title, body=body[:6000])
|
||||||
|
|
||||||
client = _get_client()
|
client = _get_client()
|
||||||
|
today = date.today().isoformat()
|
||||||
resp = client.messages.create(
|
resp = client.messages.create(
|
||||||
model=CLAUDE_MODEL,
|
model=CLAUDE_MODEL,
|
||||||
max_tokens=2048,
|
max_tokens=2048,
|
||||||
|
system=f"현재 날짜는 {today}입니다.",
|
||||||
messages=[{"role": "user", "content": prompt}],
|
messages=[{"role": "user", "content": prompt}],
|
||||||
)
|
)
|
||||||
raw = resp.content[0].text
|
raw = resp.content[0].text
|
||||||
|
|||||||
Reference in New Issue
Block a user