Spaces:
Sleeping
Sleeping
Update research_agent/prompts.py
Browse files- research_agent/prompts.py +132 -132
research_agent/prompts.py
CHANGED
|
@@ -1,132 +1,132 @@
|
|
| 1 |
-
# The system instruction now has a stronger mandate to use ONLY provided sources.
|
| 2 |
-
writer_system_instruction = """
|
| 3 |
-
You are a distinguished academic researcher. Your primary function is to synthesize information ONLY from the provided research materials.
|
| 4 |
-
You MUST ignore any of your own prior knowledge and base your writing exclusively on the text provided to you.
|
| 5 |
-
You are meticulous about citing your sources. When you make a factual claim, you MUST cite the source.
|
| 6 |
-
"""
|
| 7 |
-
|
| 8 |
-
# The planner prompt is now more forceful about using the context.
|
| 9 |
-
planner_prompt = """
|
| 10 |
-
Your task is to create a detailed report outline based on the provided research topic.
|
| 11 |
-
You MUST respond with ONLY a valid JSON object.
|
| 12 |
-
The JSON object must contain a key "sections", which is a list of objects.
|
| 13 |
-
Each object in the "sections" list MUST have two keys: "title" and "description".
|
| 14 |
-
|
| 15 |
-
Topic: '{topic}'
|
| 16 |
-
Context: {context}
|
| 17 |
-
|
| 18 |
-
Example of a perfect response:
|
| 19 |
-
{
|
| 20 |
-
"sections": [
|
| 21 |
-
{
|
| 22 |
-
"title": "Introduction to Vertical Farming",
|
| 23 |
-
"description": "A brief overview of the concept, its history, and its relevance in modern agriculture."
|
| 24 |
-
},
|
| 25 |
-
{
|
| 26 |
-
"title": "Key Technologies and Methods",
|
| 27 |
-
"description": "An exploration of the core technologies like hydroponics, aeroponics, and LED lighting that enable vertical farming."
|
| 28 |
-
}
|
| 29 |
-
]
|
| 30 |
-
}
|
| 31 |
-
"""
|
| 32 |
-
|
| 33 |
-
# The writer prompt is now more forceful about citations and ignoring prior knowledge.
|
| 34 |
-
section_writer_prompt = """
|
| 35 |
-
Your task is to write a single, detailed, and analytical section for a research paper on the topic of '{topic}'.
|
| 36 |
-
The section you are writing is: '## {section_title}'
|
| 37 |
-
|
| 38 |
-
**CRITICAL INSTRUCTIONS:**
|
| 39 |
-
1. **USE ONLY PROVIDED SOURCES:** You MUST base your writing entirely on the "Research Material" provided below. Do not add any information from your own knowledge.
|
| 40 |
-
2. **CITE EVERYTHING:** Every factual statement you make must be followed by an in-text citation in the format `[Source X]`, where 'X' is the number of the source from the list. If a single sentence synthesizes from multiple sources, cite them all (e.g., `[Source 1][Source 3]`).
|
| 41 |
-
3. **SYNTHESIZE, DON'T SUMMARIZE:** Analyze and connect the information from different sources to build a comprehensive narrative.
|
| 42 |
-
4. **FORMAL TONE:** Maintain a formal, academic tone.
|
| 43 |
-
|
| 44 |
-
**Research Material (Sources are numbered):**
|
| 45 |
-
---
|
| 46 |
-
{research}
|
| 47 |
-
---
|
| 48 |
-
Now, write the complete, cited content for the '{section_title}' section, remembering to cite every fact.
|
| 49 |
-
"""
|
| 50 |
-
|
| 51 |
-
# The final section prompt is also made more forceful.
|
| 52 |
-
final_section_writer_prompt = """
|
| 53 |
-
Your task is to write the {section_title} for a research paper on '{topic}'.
|
| 54 |
-
You MUST ONLY use the provided "Main Body Content" to write this section. Do not introduce any new information.
|
| 55 |
-
|
| 56 |
-
- For an **Introduction**, set the stage by summarizing the key themes present in the provided body content.
|
| 57 |
-
- For a **Conclusion**, synthesize the findings from the body content and discuss their implications.
|
| 58 |
-
- **At the end of the conclusion text**, add a `### Bibliography` section and list every single URL from the provided `Source URLs for Bibliography`.
|
| 59 |
-
|
| 60 |
-
**Main Body Content of the Report:**
|
| 61 |
-
---
|
| 62 |
-
{body_content}
|
| 63 |
-
---
|
| 64 |
-
|
| 65 |
-
**Source URLs for Bibliography:**
|
| 66 |
-
---
|
| 67 |
-
{source_urls}
|
| 68 |
-
---
|
| 69 |
-
Now, write the complete content for the '{section_title}' section.
|
| 70 |
-
"""
|
| 71 |
-
|
| 72 |
-
# The query writer can remain the same.
|
| 73 |
-
initial_research_prompt = """Generate 3 broad search queries for the topic: '{topic}'. Respond with ONLY a valid JSON object like this: {{"queries": ["query 1", "query 2"]}}"""
|
| 74 |
-
query_writer_prompt = """Generate {num_queries} specific search queries for the report section titled '{section_title}' about '{topic}'. Respond with ONLY a valid JSON object like this: {{"queries": ["query 1", "query 2"]}}"""
|
| 75 |
-
|
| 76 |
-
clarification_prompt_template = """
|
| 77 |
-
You are a research assistant. To provide the most relevant report on '{initial_topic}', generate 3-4 clarifying questions for the user.
|
| 78 |
-
These questions should help narrow down the scope, perspective, and focus of the research.
|
| 79 |
-
Present them as a simple, clear, numbered list.
|
| 80 |
-
"""
|
| 81 |
-
|
| 82 |
-
brief_constructor_prompt_template = """
|
| 83 |
-
Synthesize the following user request into a single, concise, and factual research topic string.
|
| 84 |
-
- User's Initial Topic: '{initial_topic}'
|
| 85 |
-
- User's Refinements: '{user_answers}'
|
| 86 |
-
RULES: Do NOT add any conversational preamble. The output MUST be a single, clean string suitable for a report title.
|
| 87 |
-
Example Output: A comprehensive analysis of Elon Musk's impact on space exploration and sustainable energy.
|
| 88 |
-
"""
|
| 89 |
-
|
| 90 |
-
expansion_prompt_template = "Given the report section '{section_title}: {section_description}', generate 3-5 specific sub-topics or key questions to investigate."
|
| 91 |
-
|
| 92 |
-
verification_prompt_template = """
|
| 93 |
-
Here is a draft of a report section and the source material it was based on.
|
| 94 |
-
Your task is to act as a fact-checker. Read the draft and verify three things:
|
| 95 |
-
1. Are there any factual claims in the draft that are NOT supported by the source material?
|
| 96 |
-
2. Are there any misinterpretations of the source material (e.g., confusing a company's sale price with an investment)?
|
| 97 |
-
3. Is the draft free of future-dated or clearly speculative dates presented as fact?
|
| 98 |
-
|
| 99 |
-
If all checks pass, respond with "OK".
|
| 100 |
-
If you find an error, respond with a corrected version of the specific sentence or paragraph.
|
| 101 |
-
|
| 102 |
-
**DRAFT TO VERIFY:**
|
| 103 |
-
---
|
| 104 |
-
{section_text}
|
| 105 |
-
---
|
| 106 |
-
|
| 107 |
-
**SOURCE MATERIAL:**
|
| 108 |
-
---
|
| 109 |
-
{research_context}
|
| 110 |
-
---
|
| 111 |
-
|
| 112 |
-
Verification Result:
|
| 113 |
-
"""
|
| 114 |
-
|
| 115 |
-
writer_prompt_template = """
|
| 116 |
-
{writer_system_instruction}
|
| 117 |
-
|
| 118 |
-
**Report So Far (for context and to avoid repetition):**
|
| 119 |
-
---
|
| 120 |
-
{previous_sections_context}
|
| 121 |
-
---
|
| 122 |
-
|
| 123 |
-
Now, using the following research material, write the next section of the report: '## {section_title}'.
|
| 124 |
-
CITE EVERY FACT using [Source X] format. Ensure your writing flows naturally from the 'Report So Far'.
|
| 125 |
-
|
| 126 |
-
**Research Material for this Section:**
|
| 127 |
-
---
|
| 128 |
-
{context_for_llm}
|
| 129 |
-
---
|
| 130 |
-
|
| 131 |
-
Section Content:
|
| 132 |
-
"""
|
|
|
|
| 1 |
+
# The system instruction now has a stronger mandate to use ONLY provided sources.
|
| 2 |
+
writer_system_instruction = """
|
| 3 |
+
You are a distinguished academic researcher. Your primary function is to synthesize information ONLY from the provided research materials.
|
| 4 |
+
You MUST ignore any of your own prior knowledge and base your writing exclusively on the text provided to you.
|
| 5 |
+
You are meticulous about citing your sources. When you make a factual claim, you MUST cite the source.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
# The planner prompt is now more forceful about using the context.
|
| 9 |
+
planner_prompt = """
|
| 10 |
+
Your task is to create a detailed report outline based on the provided research topic.
|
| 11 |
+
You MUST respond with ONLY a valid JSON object.
|
| 12 |
+
The JSON object must contain a key "sections", which is a list of objects.
|
| 13 |
+
Each object in the "sections" list MUST have two keys: "title" and "description".
|
| 14 |
+
|
| 15 |
+
Topic: '{topic}'
|
| 16 |
+
Context: {context}
|
| 17 |
+
|
| 18 |
+
Example of a perfect response:
|
| 19 |
+
{{
|
| 20 |
+
"sections": [
|
| 21 |
+
{{
|
| 22 |
+
"title": "Introduction to Vertical Farming",
|
| 23 |
+
"description": "A brief overview of the concept, its history, and its relevance in modern agriculture."
|
| 24 |
+
}},
|
| 25 |
+
{{
|
| 26 |
+
"title": "Key Technologies and Methods",
|
| 27 |
+
"description": "An exploration of the core technologies like hydroponics, aeroponics, and LED lighting that enable vertical farming."
|
| 28 |
+
}}
|
| 29 |
+
]
|
| 30 |
+
}}
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
# The writer prompt is now more forceful about citations and ignoring prior knowledge.
|
| 34 |
+
section_writer_prompt = """
|
| 35 |
+
Your task is to write a single, detailed, and analytical section for a research paper on the topic of '{topic}'.
|
| 36 |
+
The section you are writing is: '## {section_title}'
|
| 37 |
+
|
| 38 |
+
**CRITICAL INSTRUCTIONS:**
|
| 39 |
+
1. **USE ONLY PROVIDED SOURCES:** You MUST base your writing entirely on the "Research Material" provided below. Do not add any information from your own knowledge.
|
| 40 |
+
2. **CITE EVERYTHING:** Every factual statement you make must be followed by an in-text citation in the format `[Source X]`, where 'X' is the number of the source from the list. If a single sentence synthesizes from multiple sources, cite them all (e.g., `[Source 1][Source 3]`).
|
| 41 |
+
3. **SYNTHESIZE, DON'T SUMMARIZE:** Analyze and connect the information from different sources to build a comprehensive narrative.
|
| 42 |
+
4. **FORMAL TONE:** Maintain a formal, academic tone.
|
| 43 |
+
|
| 44 |
+
**Research Material (Sources are numbered):**
|
| 45 |
+
---
|
| 46 |
+
{research}
|
| 47 |
+
---
|
| 48 |
+
Now, write the complete, cited content for the '{section_title}' section, remembering to cite every fact.
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
# The final section prompt is also made more forceful.
|
| 52 |
+
final_section_writer_prompt = """
|
| 53 |
+
Your task is to write the {section_title} for a research paper on '{topic}'.
|
| 54 |
+
You MUST ONLY use the provided "Main Body Content" to write this section. Do not introduce any new information.
|
| 55 |
+
|
| 56 |
+
- For an **Introduction**, set the stage by summarizing the key themes present in the provided body content.
|
| 57 |
+
- For a **Conclusion**, synthesize the findings from the body content and discuss their implications.
|
| 58 |
+
- **At the end of the conclusion text**, add a `### Bibliography` section and list every single URL from the provided `Source URLs for Bibliography`.
|
| 59 |
+
|
| 60 |
+
**Main Body Content of the Report:**
|
| 61 |
+
---
|
| 62 |
+
{body_content}
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
**Source URLs for Bibliography:**
|
| 66 |
+
---
|
| 67 |
+
{source_urls}
|
| 68 |
+
---
|
| 69 |
+
Now, write the complete content for the '{section_title}' section.
|
| 70 |
+
"""
|
| 71 |
+
|
| 72 |
+
# The query writer can remain the same.
|
| 73 |
+
initial_research_prompt = """Generate 3 broad search queries for the topic: '{topic}'. Respond with ONLY a valid JSON object like this: {{"queries": ["query 1", "query 2"]}}"""
|
| 74 |
+
query_writer_prompt = """Generate {num_queries} specific search queries for the report section titled '{section_title}' about '{topic}'. Respond with ONLY a valid JSON object like this: {{"queries": ["query 1", "query 2"]}}"""
|
| 75 |
+
|
| 76 |
+
clarification_prompt_template = """
|
| 77 |
+
You are a research assistant. To provide the most relevant report on '{initial_topic}', generate 3-4 clarifying questions for the user.
|
| 78 |
+
These questions should help narrow down the scope, perspective, and focus of the research.
|
| 79 |
+
Present them as a simple, clear, numbered list.
|
| 80 |
+
"""
|
| 81 |
+
|
| 82 |
+
brief_constructor_prompt_template = """
|
| 83 |
+
Synthesize the following user request into a single, concise, and factual research topic string.
|
| 84 |
+
- User's Initial Topic: '{initial_topic}'
|
| 85 |
+
- User's Refinements: '{user_answers}'
|
| 86 |
+
RULES: Do NOT add any conversational preamble. The output MUST be a single, clean string suitable for a report title.
|
| 87 |
+
Example Output: A comprehensive analysis of Elon Musk's impact on space exploration and sustainable energy.
|
| 88 |
+
"""
|
| 89 |
+
|
| 90 |
+
expansion_prompt_template = "Given the report section '{section_title}: {section_description}', generate 3-5 specific sub-topics or key questions to investigate."
|
| 91 |
+
|
| 92 |
+
verification_prompt_template = """
|
| 93 |
+
Here is a draft of a report section and the source material it was based on.
|
| 94 |
+
Your task is to act as a fact-checker. Read the draft and verify three things:
|
| 95 |
+
1. Are there any factual claims in the draft that are NOT supported by the source material?
|
| 96 |
+
2. Are there any misinterpretations of the source material (e.g., confusing a company's sale price with an investment)?
|
| 97 |
+
3. Is the draft free of future-dated or clearly speculative dates presented as fact?
|
| 98 |
+
|
| 99 |
+
If all checks pass, respond with "OK".
|
| 100 |
+
If you find an error, respond with a corrected version of the specific sentence or paragraph.
|
| 101 |
+
|
| 102 |
+
**DRAFT TO VERIFY:**
|
| 103 |
+
---
|
| 104 |
+
{section_text}
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
**SOURCE MATERIAL:**
|
| 108 |
+
---
|
| 109 |
+
{research_context}
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
Verification Result:
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
writer_prompt_template = """
|
| 116 |
+
{writer_system_instruction}
|
| 117 |
+
|
| 118 |
+
**Report So Far (for context and to avoid repetition):**
|
| 119 |
+
---
|
| 120 |
+
{previous_sections_context}
|
| 121 |
+
---
|
| 122 |
+
|
| 123 |
+
Now, using the following research material, write the next section of the report: '## {section_title}'.
|
| 124 |
+
CITE EVERY FACT using [Source X] format. Ensure your writing flows naturally from the 'Report So Far'.
|
| 125 |
+
|
| 126 |
+
**Research Material for this Section:**
|
| 127 |
+
---
|
| 128 |
+
{context_for_llm}
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
Section Content:
|
| 132 |
+
"""
|