Spaces:
Sleeping
Sleeping
Download src/data_agent_baseline/agents/prompt.py from CoreModelsResearch/DAO: direct link, hf CLI and curl.
- Browser
- Download file 2.51 kB
-
https://huggingface.co/spaces/CoreModelsResearch/DAO/resolve/main/src/data_agent_baseline/agents/prompt.py
- Command line
-
hf download hf://spaces/CoreModelsResearch/DAO/src/data_agent_baseline/agents/prompt.py
-
curl -L -o prompt.py https://huggingface.co/spaces/CoreModelsResearch/DAO/resolve/main/src/data_agent_baseline/agents/prompt.py
2.51 kB
| from __future__ import annotations | |
| import json | |
| from data_agent_baseline.benchmark.schema import PublicTask | |
| REACT_SYSTEM_PROMPT = """ | |
| You are a ReAct-style data agent. | |
| You are solving a task from a public dataset. You may only read or inspect | |
| 1. files inside the task's `context/` directory through the provided tools. | |
| 2. knowledge.md for general information about the dataset and task format. | |
| Rules: | |
| 1. Use tools to inspect the available context before answering. | |
| 2. Use appropriate tools for corresponding file types (e.g., CSV tools for CSV files, JSON tools for JSON files). Do not use a SQL tool for a CSV file if a CSV tool is available. | |
| 3. Base your answer only on information you can observe through the provided tools. | |
| 4. The task is complete only when you call the `answer` tool. | |
| 5. The `answer` tool must receive a table with `columns` and `rows`. | |
| 6. Always return exactly one JSON object with keys `thought`, `action`, and `action_input`. | |
| 7. Always wrap that JSON object in exactly one fenced code block that starts with ```json and ends with ```. | |
| 8. Do not output any text before or after the fenced JSON block. | |
| Keep reasoning concise and grounded in the observed data. | |
| """.strip() | |
| RESPONSE_EXAMPLES = """ | |
| Example response when you need to inspect the context: | |
| ```json | |
| {"thought":"I should inspect the available files first.","action":"list_context","action_input":{"max_depth":4}} | |
| ``` | |
| Example response when you have the final answer: | |
| ```json | |
| {"thought":"I have the final result table.","action":"answer","action_input":{"columns":["average_long_shots"],"rows":[["63.5"]]}} | |
| ``` | |
| """.strip() | |
| def build_system_prompt(tool_descriptions: str, system_prompt: str | None = None) -> str: | |
| base_prompt = system_prompt or REACT_SYSTEM_PROMPT | |
| return ( | |
| f"{base_prompt}\n\n" | |
| "Available tools:\n" | |
| f"{tool_descriptions}\n\n" | |
| f"{RESPONSE_EXAMPLES}\n\n" | |
| "You must always return a single ```json fenced block containing one JSON object " | |
| "with keys `thought`, `action`, and `action_input`, and no extra text." | |
| ) | |
| def build_task_prompt(task: PublicTask) -> str: | |
| return ( | |
| f"Question: {task.question}\n" | |
| "All tool file paths are relative to the task context directory. " | |
| "When you have the final table, call the `answer` tool." | |
| ) | |
| def build_observation_prompt(observation: dict[str, object]) -> str: | |
| rendered = json.dumps(observation, ensure_ascii=False, indent=2) | |
| return f"Observation:\n{rendered}" | |