Skip to content

Commit

Permalink
add md2pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
qingzhong1 committed Jan 11, 2024
1 parent 06adf3f commit a3d1042
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def __init__(

async def run_search_summary(self, query: str):
responses = []
url_dict = {}
results = self.retriever_fulltext_db.search(query, top_k=3)
length_limit = 0
await self._callback_manager.on_tool_start(agent=self, tool=self.summarize_tool, input_args=query)
Expand All @@ -86,14 +85,11 @@ async def run_search_summary(self, query: str):
length_limit += len(res)
if length_limit < SUMMARIZE_MAX_LENGTH:
responses.append(data)
key = doc["title"]
value = doc["url"]
url_dict[key] = value
else:
logger.warning(f"summary size exceed {SUMMARIZE_MAX_LENGTH}")
break
await self._callback_manager.on_tool_end(self, tool=self.summarize_tool, response=responses)
return responses, url_dict
return responses

async def run(self, query: str):
"""
Expand Down Expand Up @@ -157,15 +153,15 @@ async def run(self, query: str):
# Run Sub-Queries
paragraphs_item = []
for sub_query in sub_queries:
research_result, url_dict = await self.run_search_summary(sub_query)
research_result = await self.run_search_summary(sub_query)
paragraphs_item.extend(research_result)

paragraphs = []
for item in paragraphs_item:
if item not in paragraphs:
paragraphs.append(item)
# 1. 摘要 ==> 1.摘要 for avoiding erniebot request error
research_summary = "\n\n".join([str(i) for i in paragraphs]).replace(". ", ".")
research_summary = "\n\n".join([str(i["summary"]) for i in paragraphs]).replace(". ", ".")

await self._callback_manager.on_tool_start(
agent=self, tool=self.outline_tool, input_args=sub_queries
Expand Down

0 comments on commit a3d1042

Please sign in to comment.