Update Gradio interface to handle async methods

This commit is contained in:
Steve White 2025-02-28 17:08:13 -06:00
parent 3b75436423
commit 4753e567ad
1 changed files with 13 additions and 12 deletions

View File

@ -184,19 +184,20 @@ class GradioInterface:
return markdown return markdown
async def generate_report(self, query, detail_level, custom_model=None, process_thinking_tags=False, results_file=None): async def generate_report(self, query, detail_level="standard", custom_model=None,
results_file=None, process_thinking_tags=False):
""" """
Generate a report from a query. Generate a report for the given query.
Args: Args:
query (str): The query to process query: The query to generate a report for
detail_level (str): Detail level for the report detail_level: The level of detail for the report (brief, standard, detailed, comprehensive)
custom_model (str): Custom model to use for report generation custom_model: Custom model to use for report generation
process_thinking_tags (bool): Whether to process thinking tags in the output results_file: Path to a file containing search results
results_file (str): Path to results file (optional) process_thinking_tags: Whether to process thinking tags in the model output
Returns: Returns:
tuple: (report_markdown, report_file_path) Path to the generated report
""" """
try: try:
# Create a timestamped output file # Create a timestamped output file
@ -239,10 +240,10 @@ class GradioInterface:
print(f"No results file provided, performing search for: {query}") print(f"No results file provided, performing search for: {query}")
# Process the query to create a structured query # Process the query to create a structured query
structured_query = self.query_processor.process_query(query) structured_query = await self.query_processor.process_query(query)
# Generate search queries for different engines # Generate search queries for different engines
structured_query = self.query_processor.generate_search_queries( structured_query = await self.query_processor.generate_search_queries(
structured_query, structured_query,
self.search_executor.get_available_search_engines() self.search_executor.get_available_search_engines()
) )
@ -551,9 +552,9 @@ class GradioInterface:
) )
report_button.click( report_button.click(
fn=lambda q, d, m, p, f: asyncio.run(self.generate_report(q, d, m, p, f)), fn=lambda q, d, m, r, p: asyncio.run(self.generate_report(q, d, m, r, p)),
inputs=[report_query_input, report_detail_level, report_custom_model, inputs=[report_query_input, report_detail_level, report_custom_model,
report_process_thinking, search_file_output], search_file_output, report_process_thinking],
outputs=[report_output, report_file_output] outputs=[report_output, report_file_output]
) )