ocr_mcp_ / prompts.py
vachaspathi's picture
Update prompts.py
c5b3162 verified
# prompts.py
def get_ocr_extraction_prompt(raw_text: str) -> str:
return f"""<|im_start|>system
You are a precise Data Extraction Engine.
Extract data from the text below and return a JSON object.
Fields: contact_name, total_amount, currency, invoice_date, line_items (name, quantity, rate).
Output ONLY JSON. No markdown.
<|im_end|>
<|im_start|>user
Input Text:
{raw_text[:3000]}
Return the JSON:
<|im_end|>
<|im_start|>assistant
"""
def get_agent_prompt(history_text: str, ocr_context: str, user_message: str) -> str:
# Logic: If we already have file data, hide the process_document tool
# so the model is forced to use the create tools.
tools_desc = """
1. create_record(module_name, record_data)
2. create_invoice(data)
"""
if not ocr_context:
tools_desc += "3. process_document(file_path)\n"
context_block = ""
if ocr_context:
context_block = f"""
IMPORTANT: A file was uploaded and ALREADY PROCESSED.
Here is the extracted data:
{ocr_context}
INSTRUCTIONS:
- Do NOT call process_document.
- Use the data above to fill arguments for create_record or create_invoice.
"""
return f"""<|im_start|>system
You are Zoho Assistant. Tools:
{tools_desc}
If user wants an action, return JSON: {{"tool": "name", "args": {{...}}}}
Return ONLY JSON.
<|im_end|>
<|im_start|>user
{context_block}
HISTORY:
{history_text}
REQUEST:
{user_message}
<|im_end|>
<|im_start|>assistant
"""