S3 νΌλΈλ¦¬μ±κ³Ό ν둬ννΈ λ‘κΉ μ μλννλ AI Agent κ°λ° μ¬λ‘
Agent κ°λ : λ°λ³΅ μμ μ μλννλ μ§λ₯ν μννΈμ¨μ΄ μμ΄μ νΈ
κ°λ° κ³Όμ : μ€μ νμ΅ μλ£ νλ‘μ νΈμμ ꡬνν Agent κ°λ° μ¬λ‘
class S3Publisher:
def __init__(self):
self.bucket = "ai-seminar-materials-demo"
self.profile = "shared-service"
self.region = "ap-northeast-2"
def upload_file(self, local_path, s3_key=None, content_type=None):
# Content-Type μλ κ²°μ
if content_type is None:
content_type = self._get_content_type(file_path)
# μΊμ μ μ±
μ°¨λ³ν
cache_control = ("public, max-age=31536000" if content_type.startswith("image/")
else "no-cache, no-store, must-revalidate")
# AWS CLI μ€ν
cmd = ['aws', 's3api', 'put-object',
'--profile', self.profile,
'--bucket', self.bucket,
'--key', s3_key,
'--body', str(file_path),
'--content-type', content_type,
'--cache-control', cache_control]
# νΉμ νμΌ μ
λ‘λ
s3-publish pages/actual-prompt-history.html
# μ 체 μ¬μ΄νΈ μ
λ‘λ
s3-publish --all
# μν νμΈ
s3-publish --status
class PromptLogger:
def __init__(self):
self.html_file = Path("02_web/pages/actual-prompt-history.html")
self.backup_dir = Path("05_archive/auto_backups")
def add_prompt_entry(self, user_prompt, analysis, actions, results, insights):
# 1. λ°±μ
μμ±
backup_result = self.create_backup()
# 2. μ μΉμ
μμ±
now = datetime.now()
section_id = f"prompt-{now.strftime('%Y%m%d-%H%M%S')}"
new_section = self._create_section(now, section_id, user_prompt,
analysis, actions, results, insights)
# 3. HTML μ
λ°μ΄νΈ (μ΅μ νλͺ©μ μμ μΆκ°)
content = self.html_file.read_text(encoding='utf-8')
content = content.replace(
'',
new_section + '\n '
)
# 4. νμΌ μ μ₯
self.html_file.write_text(content, encoding='utf-8')
return {"status": "success", "backup": backup_result}
# ν둬ννΈ λ‘κΉ
prompt-logger "AI νμ΅ μλ£ μμ±ν΄μ€" --analysis "νμ΅ λͺ©μ νμ
" --results "HTML νμ΄μ§ μμ±"
# λ°±μ
νμΈ
prompt-logger --list-backups
# λ‘€λ°±
prompt-logger --rollback backup_20250930_143022.html
μλν ν¨κ³Ό: μ€μ νλ‘μ νΈμμ μΈ‘μ λ ν¨μ¨μ± κ°μ μ§ν