You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
5.9 KiB

def create_plan_questions(agent, question):
query = f"""
A journalist wants to get a report that answers this question: "{question}"
THIS IS *NOT* A QUESTION YOU CAN ANSWER! Instead, you need to split it into multiple questions that can be answered through research.
The questions should be specific and focused on a single aspect of the topic.
For example, if the question is "What are the effects of climate change on agriculture?", you could split it into:
- How does temperature change affect crop yields?
- What are the impacts of changing rainfall patterns on agriculture?
- How does increased CO2 levels affect plant growth?
"""
# Add project notes summary if available
if agent.project and hasattr(agent.project, "notes_summary"):
query += f'''\nTo help you understand the subject, here is a summary of notes the journalist has done: \n"""{agent.project.notes_summary}\n"""\n'''
query += """
Answer ONLY with the questions you have divided the original question into, not the answers to them (this will be done using research in a later step).
If the original question asked by the journalist is already specific, you can keep it as is.
Answer in a structured format with each of your question on a new line.
"""
return query
def create_plan(agent, question):
"""
This function creates a research plan for answering a given question. It should be used after create_plan_questions and be in the same chat.
"""
available_sources_str = ''
for source, count in agent.available_sources.items():
if source == 'scientific articles':
available_sources_str += f'- Scientific articles the journalist has gathered. Number of articles: {count}\n'
elif source == 'other articles':
available_sources_str += f'- Other articles the journalists has gathered, such as blog posts, news articles, etc. Number of articles: {count}\n'
elif source == 'notes':
available_sources_str += f'- The journalists own notes. Number of notes: {count}\n'
elif source == 'transcribed interviews':
available_sources_str += f'- Transcribed interviews (already done, you can\'t produce new ones). Number of interviews: {count}\n'
available_sources_str += '- An analyzing tool that can analyze the information you gather.\n'
query = f"""
Thanks! Now, create a research plan for answering the original question: "{question.replace('"', "'")}".
Include the questions you just created and any additional steps needed to answer the original question.
Include what type of information you need from what available sources.
*Available sources are:*
{available_sources_str}
All of the above sources are available in a database/LLM model, but you need to specify what you need. Be as precise as possible.
You are working in a limited context and can't access the internet or external databases, and some "best practices" might not apply, like cross-referencing sources. Therefore, make the plan basic, easy to follow and with the available sources in mind.
*IMPORTANT! Each step should try to answer one or many of the questions you created, an result in a summary of the information you found.*
*Please structure the plan like:*
## Step 1:
- Task1: Description of task and outcome
- Task2: Description of task and outcome
## Step 2:
- Task1: Description of task and outcome
Etc, with as many steps and tasks as needed.
Do NOT include the writiong of the report as a step, ONLY the tasks needed to gather information. The report will be written in a later step.
*Example of a plan:*
'''
Question: "What are the effects of climate change on agriculture?"
## Step 1: Read the notes
- Task1: Read the notes and pick out the most relevant information for the question.
- Task2: Summarize the information in a structured format. Try to formulate a hypothesis based on the notes and the question.
## Step 2: Read scientific articles
- Task1: Search for scientific articles to find information about the effects of climate change on agriculture. Use the information from the first step along with the question to formulate search queries.
- Task2: Read the articles and summarize the information in a structured format. Kepp the focus on the information that is relevant for the question.
## Step 3: Analyze the information
- Task1: Use the analyzing tool to analyze the information you gathered in the previous steps. Try to find patterns and connections between the different sources.
- Task2: From the information you gathered, and in regard to the question, is there any information that contradicts each other? If so, try to find out why. Is it because of the sources, or is it because of the information itself?
## Step 4: Read other articles
- Task1: Search for other articles to find information about the effects of climate change on agriculture.
- Task2: Read the articles and summarize the information in a structured format. Pick out some interesting facts that are related to what you found in the scientific articles (if there are any).
'''
The example above is just an example, you can use other steps and tasks that are more relevant for the question.
Again: The research will be done in a restricted context, with only the available sources and tools. Therefore:
- DO NOT include any steps that require access to the internet or external databases.
- DO NOT include any steps that require cross-referencing sources.
- DO NOT include any steps to find new sources or tools.
"""
return query