Spaces:
Runtime error
Runtime error
| from smolagents.tools import Tool | |
| class HealthcareLLMVisualizerTool(Tool): | |
| name = "healthcare_llm_visualizer" | |
| description = "Creates interactive visualizations for analyzing LLM applications in Healthcare" | |
| inputs = { | |
| 'data': { | |
| 'type': 'object', | |
| 'description': 'Data for visualization in format: {"items": [{"category": "name", "value": number}]}' | |
| } | |
| } | |
| output_type = "string" | |
| def forward(self, data): | |
| """Creates a visualization from the provided data""" | |
| try: | |
| # Create React component | |
| chart_code = """ | |
| import React from 'react'; | |
| import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; | |
| const HealthcareLLMChart = () => { | |
| const data = DATA_PLACEHOLDER; | |
| return ( | |
| <div className="w-full max-w-4xl mx-auto p-4"> | |
| <h2 className="text-2xl font-bold mb-4">LLM Applications in Healthcare</h2> | |
| <div className="h-96"> | |
| <ResponsiveContainer width="100%" height="100%"> | |
| <BarChart data={data.items}> | |
| <CartesianGrid strokeDasharray="3 3" /> | |
| <XAxis dataKey="category" /> | |
| <YAxis /> | |
| <Tooltip /> | |
| <Legend /> | |
| <Bar dataKey="value" fill="#8884d8" /> | |
| </BarChart> | |
| </ResponsiveContainer> | |
| </div> | |
| </div> | |
| ); | |
| }; | |
| export default HealthcareLLMChart; | |
| """.replace('DATA_PLACEHOLDER', str(data)) | |
| return chart_code | |
| except Exception as e: | |
| return f"Error creating visualization: {str(e)}" |