-
Notifications
You must be signed in to change notification settings - Fork 500
Description
Is your feature request related to a problem? Please describe.
The ability to retain details from a document is very important for various applications. DocAgent has the ability to store documents in-memory, which allows it to answer queries about the specifics of a (relatively short) document with much more accuracy. However, the final step in DocAgent's process is always to pass to a SummaryAgent, which often loses important details from the query responses. If DocAgent is being used in a groupchat for example, then it's very difficult for other agents to get any access to doc details and not just a summary. Often, it would be much more useful to simply terminate after the query step, without summarization, and then return the full set of query responses.
Describe the solution you'd like
I would propose that we add a parameter to DocAgent, perhaps called something like detail_mode which, if set to true, terminates when QueryAgent is complete and then returns as the result of the chat the full set of queries and responses.
Here is a possible solution I would propose:
(added to DocAgent init)
detail_mode: Optional[bool] = True,near the top of DocAgent:
self.detail_mode = detail_modewhere we set the handoffs:
if self.detail_mode:
self._query_agent.handoffs.set_after_work(target=TerminateTarget())
else:
self._query_agent.handoffs.set_after_work(target=AgentTarget(agent=self._task_manager_agent))Adding a custom formatting function so that the format of the queries is consistent. It could be placed in generate_inner_group_chat_reply.
def format_query_results(query_results):
output_lines = []
for i, item in enumerate(query_results, start=1):
output_lines.append(f"{i}. **{item['query']}**")
output_lines.append(f" - {item['answer']}")
return "\n".join(output_lines)and finally in inner_group_chat_reply, changing the default return statement to:
if self.detail_mode:
formatted_block = format_query_results(context_variables.get("QueryResults", []))
return True, formatted_block
else:
return True, chat_result.summaryThis works because we're already saving the list of QueryResults in context_variables.
Additional context
No response