Determine if research mode is enabled by checking the conversation commands and 'linting' them in the selection phase

This commit is contained in:
sabaimran 2024-11-01 13:12:34 -07:00
parent cead1598b9
commit 8fd2fe162f

View file

@ -693,7 +693,6 @@ async def chat(
meta_log = conversation.conversation_log meta_log = conversation.conversation_log
is_automated_task = conversation_commands == [ConversationCommand.AutomatedTask] is_automated_task = conversation_commands == [ConversationCommand.AutomatedTask]
in_research_mode = False
researched_results = "" researched_results = ""
online_results: Dict = dict() online_results: Dict = dict()
code_results: Dict = dict() code_results: Dict = dict()
@ -712,6 +711,11 @@ async def chat(
agent=agent, agent=agent,
tracer=tracer, tracer=tracer,
) )
# If we're doing research, we don't want to do anything else
if ConversationCommand.Research in conversation_commands:
conversation_commands = [ConversationCommand.Research]
conversation_commands_str = ", ".join([cmd.value for cmd in conversation_commands]) conversation_commands_str = ", ".join([cmd.value for cmd in conversation_commands])
async for result in send_event( async for result in send_event(
ChatEvent.STATUS, f"**Chose Data Sources to Search:** {conversation_commands_str}" ChatEvent.STATUS, f"**Chose Data Sources to Search:** {conversation_commands_str}"
@ -743,7 +747,6 @@ async def chat(
): ):
if isinstance(research_result, InformationCollectionIteration): if isinstance(research_result, InformationCollectionIteration):
if research_result.summarizedResult: if research_result.summarizedResult:
in_research_mode = True
if research_result.onlineContext: if research_result.onlineContext:
online_results.update(research_result.onlineContext) online_results.update(research_result.onlineContext)
if research_result.codeContext: if research_result.codeContext:
@ -775,7 +778,7 @@ async def chat(
and len(file_filters) != 1 and len(file_filters) != 1
): ):
conversation_commands.remove(ConversationCommand.Summarize) conversation_commands.remove(ConversationCommand.Summarize)
elif ConversationCommand.Summarize in conversation_commands and not in_research_mode: elif ConversationCommand.Summarize in conversation_commands:
response_log = "" response_log = ""
agent_has_entries = await EntryAdapters.aagent_has_entries(agent) agent_has_entries = await EntryAdapters.aagent_has_entries(agent)
if len(file_filters) == 0 and not agent_has_entries: if len(file_filters) == 0 and not agent_has_entries:
@ -869,7 +872,7 @@ async def chat(
# Gather Context # Gather Context
## Extract Document References ## Extract Document References
if not in_research_mode: if not ConversationCommand.Research in conversation_commands:
try: try:
async for result in extract_references_and_questions( async for result in extract_references_and_questions(
request, request,
@ -917,7 +920,7 @@ async def chat(
conversation_commands.remove(ConversationCommand.Notes) conversation_commands.remove(ConversationCommand.Notes)
## Gather Online References ## Gather Online References
if ConversationCommand.Online in conversation_commands and not in_research_mode: if ConversationCommand.Online in conversation_commands:
try: try:
async for result in search_online( async for result in search_online(
defiltered_query, defiltered_query,
@ -943,7 +946,7 @@ async def chat(
yield result yield result
## Gather Webpage References ## Gather Webpage References
if ConversationCommand.Webpage in conversation_commands and not in_research_mode: if ConversationCommand.Webpage in conversation_commands:
try: try:
async for result in read_webpages( async for result in read_webpages(
defiltered_query, defiltered_query,
@ -981,7 +984,7 @@ async def chat(
yield result yield result
## Gather Code Results ## Gather Code Results
if ConversationCommand.Code in conversation_commands and not in_research_mode: if ConversationCommand.Code in conversation_commands:
try: try:
context = f"# Iteration 1:\n#---\nNotes:\n{compiled_references}\n\nOnline Results:{online_results}" context = f"# Iteration 1:\n#---\nNotes:\n{compiled_references}\n\nOnline Results:{online_results}"
async for result in run_code( async for result in run_code(
@ -1021,7 +1024,7 @@ async def chat(
# Generate Output # Generate Output
## Generate Image Output ## Generate Image Output
if ConversationCommand.Image in conversation_commands and not in_research_mode: if ConversationCommand.Image in conversation_commands:
async for result in text_to_image( async for result in text_to_image(
defiltered_query, defiltered_query,
user, user,