codelive007 commited on
Commit
4c23100
·
1 Parent(s): 0910b82

Revert "updated api respondes"

Browse files

This reverts commit 796143264e008c233b74814cb8a25329dcf72543.

Files changed (1) hide show
  1. mcp_server.py +19 -23
mcp_server.py CHANGED
@@ -476,10 +476,11 @@ class GradioMCPServer(MCPServer):
476
  openrouter_model=openrouter_model
477
  )
478
 
479
- def process_request(self, request: Dict[str, Any]) -> List[Any]:
480
- """Process research requests and return a list of 4 elements for the Gradio interface"""
481
  try:
482
  query = request.get('query', '')
 
483
 
484
  if self.test_mode:
485
  markdown_text = """# Test Mode Response
@@ -494,32 +495,27 @@ This is a sample report generated in test mode without using API credits.
494
  ## Test Results
495
  Sample analysis content...
496
  """
497
- # Generate both markdown and HTML files for test mode
498
- md_path = save_markdown_report(markdown_text)
499
- html_path = convert_to_html(markdown_text)
500
  else:
501
  # Use multi-agent system to process query
502
- markdown_text = self.agent_system.process_query(query)
503
- # Generate both markdown and HTML files
504
- md_path = save_markdown_report(markdown_text)
505
- html_path = convert_to_html(markdown_text)
506
-
507
- # Return list of 4 elements as expected by the Gradio interface
508
- return [
509
- "", # Empty string for value_4 Textbox component
510
- markdown_text, # Research Results Markdown content
511
- md_path, # Download Markdown Report file path
512
- html_path # Download HTML Report file path
513
- ]
514
 
515
  except Exception as e:
516
  server_logger.error(f"Error processing request: {str(e)}")
517
- return [
518
- "", # Empty string for value_4 Textbox component
519
- f"Error: {str(e)}", # Error message in Research Results
520
- "", # No markdown file to download
521
- "" # No HTML file to download
522
- ]
523
 
524
  def create_interface(self) -> gr.Blocks:
525
  """Create the Gradio interface with markdown preview and file download"""
 
476
  openrouter_model=openrouter_model
477
  )
478
 
479
+ def process_request(self, request: Dict[str, Any]) -> Dict[str, Any]:
480
+ """Process research requests and return markdown report"""
481
  try:
482
  query = request.get('query', '')
483
+ output_format = request.get('format', 'markdown')
484
 
485
  if self.test_mode:
486
  markdown_text = """# Test Mode Response
 
495
  ## Test Results
496
  Sample analysis content...
497
  """
498
+ file_path = save_markdown_report(markdown_text) if output_format == 'markdown' else convert_to_html(markdown_text)
 
 
499
  else:
500
  # Use multi-agent system to process query
501
+ report, _, _ = self.agent_system.process_query(query)
502
+ file_path = save_markdown_report(report) if output_format == 'markdown' else convert_to_html(report)
503
+ markdown_text = report
504
+
505
+ # Return response with markdown content and file path
506
+ return {
507
+ "response": markdown_text,
508
+ "file_path": file_path,
509
+ "status": "success"
510
+ }
 
 
511
 
512
  except Exception as e:
513
  server_logger.error(f"Error processing request: {str(e)}")
514
+ return {
515
+ "response": f"Error: {str(e)}",
516
+ "file_path": None,
517
+ "status": "error"
518
+ }
 
519
 
520
  def create_interface(self) -> gr.Blocks:
521
  """Create the Gradio interface with markdown preview and file download"""