원 레포랑 완전 분리
This commit is contained in:
21
workspace/utils/text_formatter.py
Normal file
21
workspace/utils/text_formatter.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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}"
|
||||
)
|
||||
Reference in New Issue
Block a user