Skip to content

Minor prompt improvements #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ollama_deep_researcher/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ def summarize_sources(state: SummaryState, config: RunnableConfig):
# Build the human message
if existing_summary:
human_message_content = (
f"<User Input> \n {state.research_topic} \n <User Input>\n\n"
f"<Existing Summary> \n {existing_summary} \n <Existing Summary>\n\n"
f"<New Search Results> \n {most_recent_web_research} \n <New Search Results>"
f"<New Context> \n {most_recent_web_research} \n <New Context>"
f"Update the Existing Summary with the New Context on this topic: \n <User Input> \n {state.research_topic} \n <User Input>\n\n"
)
else:
human_message_content = (
f"<User Input> \n {state.research_topic} \n <User Input>\n\n"
f"<Search Results> \n {most_recent_web_research} \n <Search Results>"
f"<Context> \n {most_recent_web_research} \n <Context>"
f"Create a Summary using the Context on this topic: \n <User Input> \n {state.research_topic} \n <User Input>\n\n"
)

# Run the LLM
Expand Down Expand Up @@ -256,7 +256,7 @@ def finalize_summary(state: SummaryState):

# Join the deduplicated sources
all_sources = "\n".join(unique_sources)
state.running_summary = f"## Summary\n\n{state.running_summary}\n\n ### Sources:\n{all_sources}"
state.running_summary = f"## Summary\n{state.running_summary}\n\n ### Sources:\n{all_sources}"
return {"running_summary": state.running_summary}

def route_research(state: SummaryState, config: RunnableConfig) -> Literal["finalize_summary", "web_research"]:
Expand Down
15 changes: 10 additions & 5 deletions src/ollama_deep_researcher/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_current_date():

summarizer_instructions="""
<GOAL>
Generate a high-quality summary of the web search results and keep it concise / related to the user topic.
Generate a high-quality summary of the provided context.
</GOAL>

<REQUIREMENTS>
Expand All @@ -54,7 +54,12 @@ def get_current_date():

< FORMATTING >
- Start directly with the updated summary, without preamble or titles. Do not use XML tags in the output.
< /FORMATTING >"""
< /FORMATTING >

<Task>
Think carefully about the provided Context first. Then generate a summary of the context to address the User Input.
</Task>
"""

reflection_instructions = """You are an expert research assistant analyzing a summary about {research_topic}.

Expand All @@ -74,12 +79,12 @@ def get_current_date():
- follow_up_query: Write a specific question to address this gap
</FORMAT>

<EXAMPLE>
Example output:
<Task>
Reflect carefully on the Summary to identify knowledge gaps and produce a follow-up query. Then, produce your output following this JSON format:
{{
"knowledge_gap": "The summary lacks information about performance metrics and benchmarks",
"follow_up_query": "What are typical performance benchmarks and metrics used to evaluate [specific technology]?"
}}
</EXAMPLE>
</Task>

Provide your analysis in JSON format:"""
Loading