Spaces:
Running
Running
Create prompts.py
Browse files- prompts.py +88 -0
prompts.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Prompts for the GAIA agent workflow.
|
| 3 |
+
All prompts are centralized here for easy management and version control.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
PLANNER_PROMPT_TEMPLATE = """
|
| 7 |
+
You are a master planner. You break down queries into sequential steps.
|
| 8 |
+
|
| 9 |
+
Question: {question}
|
| 10 |
+
|
| 11 |
+
Your output must be a valid JSON object matching the provided schema.
|
| 12 |
+
If you need to extract or summarize information already found in previous steps,
|
| 13 |
+
In the 'description' for 'none', clearly state what needs to be extracted from which step.
|
| 14 |
+
|
| 15 |
+
DO NOT include any conversational text, tags like <tool_call>, or markdown backticks.
|
| 16 |
+
tool_input is type string but will be converted to required format for each tool during execution.
|
| 17 |
+
|
| 18 |
+
IMPORTANT - Special handling for load_and_analyze_excel_file:
|
| 19 |
+
When using load_and_analyze_excel_file, the tool_input MUST contain BOTH the query and file path separated by a pipe (|).
|
| 20 |
+
Format: "query_text|/path/to/file.csv"
|
| 21 |
+
Example: "Count all meerkats above ground|/home/nitin/Desktop/data.csv"
|
| 22 |
+
|
| 23 |
+
Use the following tools if needed:
|
| 24 |
+
- web_search: for searching the web for relevant information.
|
| 25 |
+
- wikisearch: for searching Wikipedia for relevant information.
|
| 26 |
+
- youtube_transcript: for fetching YouTube video transcripts relevant to the question.
|
| 27 |
+
- load_and_analyze_excel_file: for analyzing data from Excel/CSV files. Requires query and file_path separated by pipe (|).
|
| 28 |
+
- extract_text_from_image: for extracting text from image files relevant to the question.
|
| 29 |
+
- transcribe_audio: for transcribing audio files and returning the transcript.
|
| 30 |
+
- addition_tool: for adding two numbers.
|
| 31 |
+
- subtraction_tool: for subtracting two numbers.
|
| 32 |
+
- multiplication_tool: for multiplying two numbers.
|
| 33 |
+
|
| 34 |
+
Example Output:
|
| 35 |
+
{{
|
| 36 |
+
"steps": [
|
| 37 |
+
{{"step_number": 1, "description": "Search for X", "tool": "web_search", "tool_input": "France population millions"}},
|
| 38 |
+
{{"step_number": 2, "description": "Analyze Excel data", "tool": "load_and_analyze_excel_file", "tool_input": "Count meerkats above ground|/path/to/file.csv"}},
|
| 39 |
+
{{"step_number": 3, "description": "Calculate sum of 50 and 20", "tool": "addition_tool", "tool_input": "50,20"}},
|
| 40 |
+
{{"step_number": 4, "description": "Extract final answer", "tool": "none", "tool_input": "Summarize results from step 1-3"}}
|
| 41 |
+
]
|
| 42 |
+
}}
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
FINALIZER_PROMPT_TEMPLATE = """
|
| 46 |
+
You are a helpful AI assistant. A question has been answered. Provide the final answer using the provided intermediate results from the steps taken to answer the question.
|
| 47 |
+
|
| 48 |
+
YOUR FINAL ANSWER should be:
|
| 49 |
+
- A number OR
|
| 50 |
+
- As few words as possible OR
|
| 51 |
+
- A comma separated list of numbers and/or strings
|
| 52 |
+
|
| 53 |
+
Keep it short and concise. Do not include any explanations, just the final answer.
|
| 54 |
+
|
| 55 |
+
FORMATTING RULES:
|
| 56 |
+
- If you are asked for a number: don't use comma to write your number, neither use units such as $ or percent sign unless specified otherwise.
|
| 57 |
+
- If you are asked for a string: don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
|
| 58 |
+
- If you are asked for a comma separated list: apply the above rules depending on whether the element is a number or a string.
|
| 59 |
+
|
| 60 |
+
Question: {question}
|
| 61 |
+
|
| 62 |
+
Intermediate Steps and results:
|
| 63 |
+
{intermediate_results}
|
| 64 |
+
|
| 65 |
+
Example: if intermediate result says 'The final answer is 42.' your final answer should be just:
|
| 66 |
+
42
|
| 67 |
+
|
| 68 |
+
Provide exact final answer without any additional text.
|
| 69 |
+
"""
|
| 70 |
+
|
| 71 |
+
EXCEL_ANALYSIS_PROMPT_TEMPLATE = """
|
| 72 |
+
You are a data analyst. Analyze the following data and answer the question.
|
| 73 |
+
|
| 74 |
+
Data Summary:
|
| 75 |
+
{data_summary}
|
| 76 |
+
|
| 77 |
+
User Question: {query}
|
| 78 |
+
|
| 79 |
+
Provide a clear, concise answer based on the data provided. If you need to perform calculations, do them based on the data shown.
|
| 80 |
+
"""
|
| 81 |
+
|
| 82 |
+
WEB_SEARCH_EXTRACTION_PROMPT_TEMPLATE = """
|
| 83 |
+
From these search results: {search_results}
|
| 84 |
+
|
| 85 |
+
Extract the most relevant information that answers the query: '{query}'
|
| 86 |
+
|
| 87 |
+
Return a concise, factual answer.
|
| 88 |
+
"""
|