Spaces:
Running
on
Zero
Running
on
Zero
| from typing import Callable | |
| PROMPTS_SYS = { | |
| "default": lambda base_text: (f"Below is an image of a document page along with its dimensions. " | |
| f"Simply return the markdown representation of this document, presenting tables in markdown format as they naturally appear.\n" | |
| f"If the document contains images, use a placeholder like dummy.png for each image.\n" | |
| f"Your final output must be in JSON format with a single key `natural_text` containing the response.\n" | |
| f"RAW_TEXT_START\n{base_text}\nRAW_TEXT_END"), | |
| "structure": lambda base_text: ( | |
| f"Below is an image of a document page, along with its dimensions and possibly some raw textual content previously extracted from it. " | |
| f"Note that the text extraction may be incomplete or partially missing. Carefully consider both the layout and any available text to reconstruct the document accurately.\n" | |
| f"Your task is to return the markdown representation of this document, presenting tables in HTML format as they naturally appear.\n" | |
| f"If the document contains images or figures, analyze them and include the tag <figure>IMAGE_ANALYSIS</figure> in the appropriate location.\n" | |
| f"Your final output must be in JSON format with a single key `natural_text` containing the response.\n" | |
| f"RAW_TEXT_START\n{base_text}\nRAW_TEXT_END" | |
| ), | |
| } | |
| def get_prompt(prompt_name: str) -> Callable[[str], str]: | |
| """ | |
| Fetches the system prompt based on the provided PROMPT_NAME. | |
| :param prompt_name: The identifier for the desired prompt. | |
| :return: The system prompt as a string. | |
| """ | |
| return PROMPTS_SYS.get(prompt_name, lambda x: "Invalid PROMPT_NAME provided.") |