@@ -35,12 +35,11 @@ async def generate_serp_queries(
3535) -> List [SerpQuery ]:
3636 """Generate SERP queries based on user input and previous learnings."""
3737
38- # prompt = f"""Given the following prompt from the user, generate a list of SERP queries to research the topic. Return a JSON object with a 'queries' array field containing {num_queries} queries (or less if the original prompt is clear). Each query object should have 'query' and 'research_goal' fields. Make sure each query is unique and not similar to each other: <prompt>{query}</prompt>"""
39- prompt = f"""根据用户提供的以下提示,生成SERP(Search Engine Results Page ,搜索引擎结果页面)查询列表以研究该主题。
40- 返回一个JSON对象,其中包含'queries'数组字段,该字段包含{ num_queries } 个查询(如果原始提示已经很明确,则可以少于此数量)。
41- 每个查询对象应有'query'和'research_goal'字段。
42- 确保每个查询都是唯一的,层层递进的,彼此之间不要相似。
43- 请注意JSON对象一定要格式正确,不要输出其他额外内容。"""
38+ prompt = f"""根据用户的以下提示,生成一系列SERP查询来研究该主题。
39+ 返回一个JSON对象,其中包含一个'queries'数组字段,包含{ num_queries } 个查询(如果原始提示已经很明确,则可以少于这个数量)。
40+ 每个查询对象应该有'query'和'research_goal'字段。
41+ 请注意JSON对象一定要格式正确,不要输出其他额外内容。
42+ 确保每个查询都是唯一的,且彼此不相似:主题<prompt>{ query } </prompt>"""
4443 if learnings :
4544 # prompt += f"\n\nHere are some learnings from previous research, use them to generate more specific queries: {' '.join(learnings)}"
4645 prompt += f"\n \n 这里是之前研究步骤的一些发现,请使用它们生成更具体的查询:{ ' ' .join (learnings )} 。请确保生成的查询与用户原始提示的语言保持一致。"
@@ -54,8 +53,6 @@ async def generate_serp_queries(
5453 ],
5554 response_format = {"type" : "json_object" },
5655 )
57- loguru .logger .info ("generate_serp_queries done:" )
58- loguru .logger .info (response )
5956 try :
6057 queries = response .get ("queries" , [])
6158 return [SerpQuery (** q ) for q in queries ][:num_queries ]
@@ -84,15 +81,6 @@ async def process_serp_result(
8481 # Create the contents string separately
8582 contents_str = "" .join (f"<content>\n { content } \n </content>" for content in contents )
8683
87- # prompt = (
88- # f"Given the following contents from a SERP search for the query <query>{query}</query>, "
89- # f"generate a list of learnings from the contents. Return a JSON object with 'learnings' "
90- # f"and 'followUpQuestions' keys with array of strings as values. Include up to {num_learnings} learnings and "
91- # f"{num_follow_up_questions} follow-up questions. The learnings should be unique, "
92- # "concise, and information-dense, including entities, metrics, numbers, and dates.\n\n"
93- # f"<contents>{contents_str}</contents>"
94- # )
95-
9684 prompt = (
9785 f"根据以下对查询<query>{ query } </query>的SERP搜索内容,"
9886 f"生成从内容中得到的学习要点列表。返回一个JSON对象,包含'learnings'和'followUpQuestions'键(key),"
@@ -139,19 +127,11 @@ async def write_final_report(
139127 150_000 ,
140128 )
141129
142- # user_prompt = (
143- # f"Given the following prompt from the user, write a final report on the topic using "
144- # f"the learnings from research. Return a JSON object with a 'reportMarkdown' field "
145- # f"containing a detailed markdown report (aim for 3+ pages). Include ALL the learnings "
146- # f"from research:\n\n<prompt>{prompt}</prompt>\n\n"
147- # f"Here are all the learnings from research:\n\n<learnings>\n{learnings_string}\n</learnings>"
148- # )
149130 user_prompt = (
150131 f"根据以下用户提供的提示,使用研究中获得的学习要点撰写关于该主题的最终报告。返回一个JSON对象,"
151- f"其中包含'reportMarkdown'字段,该字段包含详细的markdown报告(目标为3+页) 。包括研究中的所有学习要点:\n \n "
132+ f"其中包含'reportMarkdown'字段,该字段包含详细的markdown报告(目标为3页以上),尽量内容丰富饱满 。包括研究中的所有学习要点:\n \n "
152133 f"<prompt>{ prompt } </prompt>\n \n "
153134 f"以下是研究中获得的所有学习要点:\n \n <learnings>\n { learnings_string } \n </learnings>"
154- f"请确保生成的报告与用户原始提示({ prompt } )的语言保持一致。"
155135 )
156136 response = await get_client_response (
157137 client = client ,
@@ -167,7 +147,7 @@ async def write_final_report(
167147 report = response .get ("reportMarkdown" , "" )
168148
169149 # Append sources
170- urls_section = "\n \n ## Sources \n \n " + "\n " .join (
150+ urls_section = "\n \n ## 来源 \n \n " + "\n " .join (
171151 [f"- { url } " for url in visited_urls ]
172152 )
173153 return report + urls_section
@@ -216,7 +196,7 @@ async def process_query(serp_query: SerpQuery) -> ResearchResult:
216196 async with semaphore :
217197 try :
218198 # Search for content
219- result = await search_service .search (serp_query .query , limit = 5 )
199+ result = await search_service .search (serp_query .query , limit = 2 )
220200 loguru .logger .info ("process_query:" )
221201 loguru .logger .info (result )
222202 # Collect new URLs
0 commit comments