Catch error in call to data sources, output format selection tool AI

Previously if the call to this tool AI failed, the API call would
non-gracefully fail on server. This would leave the client hanging in
a wierd state (e.g with spinner running on web app with no indication
of issue).

Also do not show filters in query debug log lines when no filters in query
This commit is contained in:
Debanjum
2025-01-12 21:33:30 +07:00
parent 24ab8450ba
commit 9355381fac
2 changed files with 17 additions and 11 deletions

View File

@@ -392,7 +392,8 @@ async def extract_references_and_questions(
filters_in_query += " ".join([f'file:"{filter}"' for filter in conversation.file_filters])
using_offline_chat = False
logger.debug(f"Filters in query: {filters_in_query}")
if is_none_or_empty(filters_in_query):
logger.debug(f"Filters in query: {filters_in_query}")
personality_context = prompts.personality_context.format(personality=agent.personality) if agent else ""

View File

@@ -785,16 +785,21 @@ async def chat(
program_execution_context: List[str] = []
if conversation_commands == [ConversationCommand.Default]:
chosen_io = await aget_data_sources_and_output_format(
q,
meta_log,
is_automated_task,
user=user,
query_images=uploaded_images,
agent=agent,
query_files=attached_file_context,
tracer=tracer,
)
try:
chosen_io = await aget_data_sources_and_output_format(
q,
meta_log,
is_automated_task,
user=user,
query_images=uploaded_images,
agent=agent,
query_files=attached_file_context,
tracer=tracer,
)
except ValueError as e:
logger.error(f"Error getting data sources and output format: {e}. Falling back to default.")
conversation_commands = [ConversationCommand.General]
conversation_commands = chosen_io.get("sources") + [chosen_io.get("output")]
# If we're doing research, we don't want to do anything else