Files
llm-gateway-sub-backup/workspace/utils/text_formatter.py
2025-08-11 18:56:38 +09:00

21 lines
888 B
Python

class PromptFormatter:
SYSTEM_PROMPT = """
다음은 스캔된 공문서에서 OCR로 추출된 원시 텍스트입니다.
오타나 줄바꿈 오류가 있을 수 있으니 의미를 유추하여 정확한 정보를 추출해주세요.
다음 주어진 항목을 JSON 형식(```json)으로 작성해주세요:
"""
@staticmethod
def format(text: str, user_prompt: str = None, custom_mode: bool = False, prompt_mode: str = "extract") -> str:
if custom_mode and prompt_mode == "extract":
return (
f"{PromptFormatter.SYSTEM_PROMPT}\n\n"
f"{user_prompt}\n\n"
f"다음은 OCR로 추출된 원시 텍스트입니다:\n\n{text}"
)
else:
return (
f"{user_prompt}\n\n"
f"다음은 OCR로 추출된 원시 텍스트입니다:\n\n{text}"
)