File size: 1,591 Bytes
ff6980a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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)}"