diff --git a/apex/services/deep_research/deep_research_langchain.py b/apex/services/deep_research/deep_research_langchain.py index e4a98842..c1f36c25 100644 --- a/apex/services/deep_research/deep_research_langchain.py +++ b/apex/services/deep_research/deep_research_langchain.py @@ -25,6 +25,16 @@ class DeepResearchLangchain(DeepResearchBase): + _FINAL_ANSWER_INST = ( + "You are a senior interdisciplinary researcher with expertise across " + "science, technology, humanities, and social sciences.\n" + "Provide report only in plain text using natural language.\n" + "Write your response in the form of a well-structured research report with sections:\n" + "Executive Summary, Key Findings, Evidence, Limitations, Conclusion.\n" + "Use inline numeric citations like [1], [2] that refer to Sources.\n" + "At the end, include a 'Sources' section listing the numbered citations.\n\n" + ) + def __init__( self, key: str, @@ -142,6 +152,7 @@ async def invoke( reasoning_traces: list[dict[str, Any]] = [] question = messages[-1]["content"] + question = self._FINAL_ANSWER_INST + question # Seed notes with any provided documents notes: list[str] = [] @@ -297,14 +308,7 @@ async def invoke( final_prompt = PromptTemplate( input_variables=["question", "notes", "sources"], template=( - "You are a senior interdisciplinary researcher with expertise across " - "science, technology, humanities, and social sciences.\n" - "Provide report only in plain text using natural language.\n" - "Write your response in the form of a well-structured research report with sections:\n" - "Executive Summary, Key Findings, Evidence, Limitations, Conclusion.\n" - "Use inline numeric citations like [1], [2] that refer to Sources.\n" - "At the end, include a 'Sources' section listing the numbered citations.\n\n" - "Do NOT use JSON, or any other structured data format.\n" + self._FINAL_ANSWER_INST + "Do NOT use JSON, or any other structured data format.\n" "Question:\n{question}\n\n" "Notes:\n{notes}\n\n" "Sources:\n{sources}\n\n" diff --git a/apex/validator/generate_reference.py b/apex/validator/generate_reference.py index 61d7f57b..4b0e39d3 100644 --- a/apex/validator/generate_reference.py +++ b/apex/validator/generate_reference.py @@ -26,11 +26,7 @@ async def generate_reference( } user_message: dict[str, str] = { "role": "user", - "content": ( - f"Research Question: {query}\n\n" - "Please think through the answer carefully, annotate each step with citations like [1], [2], etc., " - 'and conclude with a "Sources:" list mapping each [n] to its source URL or title.' - ), + "content": query, } response, tool_history, reasoning_traces = await llm.invoke([system_message, user_message])