Commit
·
4c23100
1
Parent(s):
0910b82
Revert "updated api respondes"
Browse filesThis reverts commit 796143264e008c233b74814cb8a25329dcf72543.
- 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]) ->
|
480 |
-
"""Process research requests and return
|
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 |
-
|
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 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
"",
|
510 |
-
|
511 |
-
|
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 |
-
""
|
519 |
-
|
520 |
-
""
|
521 |
-
|
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"""
|