JatinAutonomousLabs commited on
Commit
c5c6773
·
verified ·
1 Parent(s): d73e344

Upload 3 files

Browse files
plugins/outputs/chart_generator.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Chart Generation Plugin"""
3
+ import plotly.express as px
4
+ import plotly.graph_objects as go
5
+ from typing import Dict, Any
6
+ import pandas as pd
7
+ import json
8
+
9
+ class ChartGenerator:
10
+ """Generate interactive charts."""
11
+ def create_chart_html(self, data: pd.DataFrame, chart_type: str, x: str, y: str = None,
12
+ title: str = "Chart", color: str = None, **kwargs) -> str:
13
+
14
+ if data.empty or x not in data.columns:
15
+ return json.dumps({"error": "Invalid data"})
16
+
17
+ try:
18
+ if chart_type == "bar":
19
+ fig = px.bar(data, x=x, y=y, title=title, color=color, **kwargs)
20
+ elif chart_type == "line":
21
+ fig = px.line(data, x=x, y=y, title=title, color=color, **kwargs)
22
+ elif chart_type == "scatter":
23
+ fig = px.scatter(data, x=x, y=y, title=title, color=color, **kwargs)
24
+ elif chart_type == "pie":
25
+ fig = px.pie(data, names=x, values=y, title=title, **kwargs)
26
+ else:
27
+ fig = px.bar(data, x=x, y=y, title=title)
28
+
29
+ fig.update_layout(template="plotly_white", height=400)
30
+ return fig.to_json()
31
+ except Exception as e:
32
+ return json.dumps({"error": str(e)})
plugins/outputs/report_generator.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Report Generation Plugin"""
3
+ from typing import Dict, Any, List
4
+ from datetime import datetime
5
+
6
+ class ReportGenerator:
7
+ """Generate formatted reports."""
8
+
9
+ def generate_markdown_report(self, title: str, sections: List[Dict[str, Any]]) -> str:
10
+ """Generate markdown formatted report."""
11
+ report = [f"# {title}", f"*Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*", ""]
12
+
13
+ for section in sections:
14
+ report.append(f"## {section.get('heading', 'Section')}")
15
+ report.append(section.get('content', ''))
16
+ report.append("")
17
+
18
+ return "\n".join(report)
19
+
20
+ def generate_summary(self, data: Dict[str, Any]) -> str:
21
+ """Generate executive summary."""
22
+ summary = ["## Executive Summary", ""]
23
+ for key, value in data.items():
24
+ summary.append(f"**{key}:** {value}")
25
+ return "\n".join(summary)
plugins/outputs/table_formatter.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Table Formatting Plugin"""
3
+ import pandas as pd
4
+ from tabulate import tabulate
5
+
6
+ class TableFormatter:
7
+ """Format DataFrames as tables."""
8
+ def format_to_markdown(self, df: pd.DataFrame, headers: str = "keys") -> str:
9
+ if df.empty:
10
+ return "No data to display."
11
+ return tabulate(df, headers=headers, tablefmt="github", showindex=False)
12
+
13
+ def format_to_html(self, df: pd.DataFrame) -> str:
14
+ if df.empty:
15
+ return "No data to display."
16
+ return df.to_html(index=False, classes="table-auto w-full text-left border")