Skip to content

Commit 5e53626

Browse files
authored
Merge pull request #81 from langchain-ai/rlm/save_report
Minor prompt improvements
2 parents 24db21f + 6ca0d46 commit 5e53626

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/ollama_deep_researcher/graph.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ def summarize_sources(state: SummaryState, config: RunnableConfig):
135135
# Build the human message
136136
if existing_summary:
137137
human_message_content = (
138-
f"<User Input> \n {state.research_topic} \n <User Input>\n\n"
139138
f"<Existing Summary> \n {existing_summary} \n <Existing Summary>\n\n"
140-
f"<New Search Results> \n {most_recent_web_research} \n <New Search Results>"
139+
f"<New Context> \n {most_recent_web_research} \n <New Context>"
140+
f"Update the Existing Summary with the New Context on this topic: \n <User Input> \n {state.research_topic} \n <User Input>\n\n"
141141
)
142142
else:
143143
human_message_content = (
144-
f"<User Input> \n {state.research_topic} \n <User Input>\n\n"
145-
f"<Search Results> \n {most_recent_web_research} \n <Search Results>"
144+
f"<Context> \n {most_recent_web_research} \n <Context>"
145+
f"Create a Summary using the Context on this topic: \n <User Input> \n {state.research_topic} \n <User Input>\n\n"
146146
)
147147

148148
# Run the LLM
@@ -256,7 +256,7 @@ def finalize_summary(state: SummaryState):
256256

257257
# Join the deduplicated sources
258258
all_sources = "\n".join(unique_sources)
259-
state.running_summary = f"## Summary\n\n{state.running_summary}\n\n ### Sources:\n{all_sources}"
259+
state.running_summary = f"## Summary\n{state.running_summary}\n\n ### Sources:\n{all_sources}"
260260
return {"running_summary": state.running_summary}
261261

262262
def route_research(state: SummaryState, config: RunnableConfig) -> Literal["finalize_summary", "web_research"]:

src/ollama_deep_researcher/prompts.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_current_date():
3333

3434
summarizer_instructions="""
3535
<GOAL>
36-
Generate a high-quality summary of the web search results and keep it concise / related to the user topic.
36+
Generate a high-quality summary of the provided context.
3737
</GOAL>
3838
3939
<REQUIREMENTS>
@@ -54,7 +54,12 @@ def get_current_date():
5454
5555
< FORMATTING >
5656
- Start directly with the updated summary, without preamble or titles. Do not use XML tags in the output.
57-
< /FORMATTING >"""
57+
< /FORMATTING >
58+
59+
<Task>
60+
Think carefully about the provided Context first. Then generate a summary of the context to address the User Input.
61+
</Task>
62+
"""
5863

5964
reflection_instructions = """You are an expert research assistant analyzing a summary about {research_topic}.
6065
@@ -74,12 +79,12 @@ def get_current_date():
7479
- follow_up_query: Write a specific question to address this gap
7580
</FORMAT>
7681
77-
<EXAMPLE>
78-
Example output:
82+
<Task>
83+
Reflect carefully on the Summary to identify knowledge gaps and produce a follow-up query. Then, produce your output following this JSON format:
7984
{{
8085
"knowledge_gap": "The summary lacks information about performance metrics and benchmarks",
8186
"follow_up_query": "What are typical performance benchmarks and metrics used to evaluate [specific technology]?"
8287
}}
83-
</EXAMPLE>
88+
</Task>
8489
8590
Provide your analysis in JSON format:"""

0 commit comments

Comments
 (0)