ai-chart-toolkit 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ai-chart-toolkit might be problematic. Click here for more details.

@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ ai-chart-toolkit - Universal Blueprint & Visual Diagram Generator for AI Agents
4
+ Supports flowcharts, hierarchy architecture trees, donut charts, pie charts,
5
+ concentric telemetry rings, and precision radial gauges.
6
+ """
7
+
8
+ __version__ = "1.0.0"
9
+
10
+ from .engine import (
11
+ generate_flowchart,
12
+ generate_hierarchy_chart,
13
+ generate_pie_chart,
14
+ generate_circular_rings,
15
+ generate_circular_gauge,
16
+ PALETTES
17
+ )
18
+ from .tool import execute_chart_tool
19
+ from .schemas import (
20
+ UNIFIED_TOOL_SCHEMA,
21
+ get_openai_tool_schema,
22
+ get_claude_tool_schema,
23
+ get_gemini_tool_schema
24
+ )
25
+
26
+ __all__ = [
27
+ "generate_flowchart",
28
+ "generate_hierarchy_chart",
29
+ "generate_pie_chart",
30
+ "generate_circular_rings",
31
+ "generate_circular_gauge",
32
+ "execute_chart_tool",
33
+ "UNIFIED_TOOL_SCHEMA",
34
+ "get_openai_tool_schema",
35
+ "get_claude_tool_schema",
36
+ "get_gemini_tool_schema",
37
+ "PALETTES",
38
+ "__version__"
39
+ ]
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+ from .tool import main
3
+
4
+ if __name__ == "__main__":
5
+ main()
@@ -0,0 +1,83 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ ai_chart_toolkit.api_server
4
+ Zero-dependency HTTP REST API server for web agents, cURL, and cloud integrations.
5
+ Listens on port 8000 by default (configurable via PORT env var).
6
+ """
7
+
8
+ import os
9
+ import sys
10
+ import json
11
+ from http.server import HTTPServer, BaseHTTPRequestHandler
12
+ from .tool import execute_chart_tool
13
+ from .schemas import UNIFIED_TOOL_SCHEMA
14
+
15
+ class ChartHTTPHandler(BaseHTTPRequestHandler):
16
+ def _send_json(self, status_code: int, data: dict):
17
+ body = json.dumps(data, indent=2).encode("utf-8")
18
+ self.send_response(status_code)
19
+ self.send_header("Content-Type", "application/json")
20
+ self.send_header("Content-Length", str(len(body)))
21
+ self.send_header("Access-Control-Allow-Origin", "*")
22
+ self.send_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
23
+ self.send_header("Access-Control-Allow-Headers", "Content-Type")
24
+ self.end_headers()
25
+ self.wfile.write(body)
26
+
27
+ def do_OPTIONS(self):
28
+ self._send_json(200, {"status": "ok"})
29
+
30
+ def do_GET(self):
31
+ if self.path in ["/", "/health"]:
32
+ self._send_json(200, {
33
+ "service": "ai-chart-toolkit-api",
34
+ "version": "1.0.0",
35
+ "status": "healthy",
36
+ "endpoints": {
37
+ "POST /render": "Execute chart generation with JSON payload",
38
+ "GET /schema": "Retrieve tool definition JSON schema",
39
+ "GET /health": "Health check"
40
+ }
41
+ })
42
+ elif self.path == "/schema":
43
+ self._send_json(200, UNIFIED_TOOL_SCHEMA)
44
+ else:
45
+ self._send_json(404, {"error": "Not Found"})
46
+
47
+ def do_POST(self):
48
+ if self.path in ["/render", "/generate"]:
49
+ content_length = int(self.headers.get("Content-Length", 0))
50
+ if content_length == 0:
51
+ self._send_json(400, {"success": False, "error": "Empty request body."})
52
+ return
53
+
54
+ body = self.rfile.read(content_length).decode("utf-8")
55
+ try:
56
+ payload = json.loads(body)
57
+ except json.JSONDecodeError as e:
58
+ self._send_json(400, {"success": False, "error": f"Invalid JSON: {e}"})
59
+ return
60
+
61
+ chart_type = payload.pop("chart_type", payload.pop("type", "flowchart"))
62
+ result = execute_chart_tool(chart_type, payload)
63
+ status = 200 if result.get("success") else 400
64
+ self._send_json(status, result)
65
+ else:
66
+ self._send_json(404, {"error": f"Path '{self.path}' not found. Use POST /render."})
67
+
68
+ def log_message(self, format, *args):
69
+ sys.stderr.write(f"[{self.log_date_time_string()}] {format % args}\n")
70
+
71
+ def main():
72
+ port = int(os.environ.get("PORT", 8000))
73
+ host = os.environ.get("HOST", "0.0.0.0")
74
+ server = HTTPServer((host, port), ChartHTTPHandler)
75
+ sys.stderr.write(f"ai-chart-toolkit REST API running on http://{host}:{port}\n")
76
+ try:
77
+ server.serve_forever()
78
+ except KeyboardInterrupt:
79
+ sys.stderr.write("Server shutting down.\n")
80
+ server.server_close()
81
+
82
+ if __name__ == "__main__":
83
+ main()
Binary file