deeptutor-visualize 1.7.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.
Files changed (30) hide show
  1. deeptutor/agents/visualize/__init__.py +5 -0
  2. deeptutor/agents/visualize/agents/__init__.py +11 -0
  3. deeptutor/agents/visualize/agents/analysis_agent.py +102 -0
  4. deeptutor/agents/visualize/agents/code_generator_agent.py +117 -0
  5. deeptutor/agents/visualize/agents/review_agent.py +75 -0
  6. deeptutor/agents/visualize/capability.py +571 -0
  7. deeptutor/agents/visualize/models.py +120 -0
  8. deeptutor/agents/visualize/pipeline.py +91 -0
  9. deeptutor/agents/visualize/prompts/en/analysis_agent.yaml +132 -0
  10. deeptutor/agents/visualize/prompts/en/code_generator_agent.yaml +189 -0
  11. deeptutor/agents/visualize/prompts/en/review_agent.yaml +38 -0
  12. deeptutor/agents/visualize/prompts/en/visualize.yaml +14 -0
  13. deeptutor/agents/visualize/prompts/zh/analysis_agent.yaml +123 -0
  14. deeptutor/agents/visualize/prompts/zh/code_generator_agent.yaml +161 -0
  15. deeptutor/agents/visualize/prompts/zh/review_agent.yaml +35 -0
  16. deeptutor/agents/visualize/prompts/zh/visualize.yaml +14 -0
  17. deeptutor/agents/visualize/utils.py +210 -0
  18. deeptutor/api/routers/visualizers.py +144 -0
  19. deeptutor/visualizers/README.md +79 -0
  20. deeptutor/visualizers/__init__.py +20 -0
  21. deeptutor/visualizers/builtin.py +369 -0
  22. deeptutor/visualizers/loop_capability.py +125 -0
  23. deeptutor/visualizers/protocol.py +225 -0
  24. deeptutor/visualizers/registry.py +155 -0
  25. deeptutor/visualizers/store.py +260 -0
  26. deeptutor/visualizers/tool.py +150 -0
  27. deeptutor_visualize-1.7.0.dist-info/METADATA +6 -0
  28. deeptutor_visualize-1.7.0.dist-info/RECORD +30 -0
  29. deeptutor_visualize-1.7.0.dist-info/WHEEL +5 -0
  30. deeptutor_visualize-1.7.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,150 @@
1
+ """Agent-loop submission tool for validated visualization envelopes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from deeptutor.core.context import UnifiedContext
8
+ from deeptutor.core.tool_protocol import BaseTool, ToolDefinition, ToolParameter, ToolResult
9
+
10
+ from .protocol import (
11
+ REQUESTED_VISUALIZER_KEY,
12
+ VISUALIZATION_RESULT_KEY,
13
+ RendererRef,
14
+ VisualizationEnvelope,
15
+ VisualizationInteraction,
16
+ VisualizationPayload,
17
+ VisualizationPresentation,
18
+ )
19
+ from .registry import VisualizerRegistry, get_visualizer_registry
20
+
21
+
22
+ class SubmitVisualizationTool(BaseTool):
23
+ """The only commit point from the chat loop into the canvas protocol."""
24
+
25
+ def get_definition(self) -> ToolDefinition:
26
+ return ToolDefinition(
27
+ name="submit_visualization",
28
+ description=(
29
+ "Validate and submit one complete visualization to DeepTutor's canvas. "
30
+ "Call this after choosing an installed visualizer and generating its exact "
31
+ "payload. If validation fails, repair the payload and call again."
32
+ ),
33
+ parameters=[
34
+ ToolParameter(
35
+ name="visualizer",
36
+ type="string",
37
+ description=(
38
+ "Installed visualization type to render. Use one exact id "
39
+ "from the visualization protocol in the system prompt."
40
+ ),
41
+ ),
42
+ ToolParameter(
43
+ name="payload",
44
+ type="string",
45
+ description=(
46
+ "Complete raw payload in the selected type's declared format. "
47
+ "Do not wrap it in Markdown fences."
48
+ ),
49
+ ),
50
+ ToolParameter(name="title", type="string", description="Short title."),
51
+ ToolParameter(
52
+ name="description",
53
+ type="string",
54
+ description="One sentence explaining what to explore or notice.",
55
+ ),
56
+ ToolParameter(
57
+ name="alt_text",
58
+ type="string",
59
+ description="Accessible description of the important visual content.",
60
+ ),
61
+ ],
62
+ )
63
+
64
+ async def execute(self, **kwargs: Any) -> ToolResult:
65
+ context = kwargs.get("_visualize_context")
66
+ if not isinstance(context, UnifiedContext):
67
+ return ToolResult(content="Visualization context is unavailable.", success=False)
68
+ registry = kwargs.get("_visualizer_registry")
69
+ if not isinstance(registry, VisualizerRegistry):
70
+ registry = get_visualizer_registry()
71
+
72
+ visualizer_id = str(kwargs.get("visualizer") or "").strip().lower()
73
+ requested = (
74
+ str(
75
+ kwargs.get("_requested_visualizer")
76
+ or context.metadata.get(REQUESTED_VISUALIZER_KEY)
77
+ or "auto"
78
+ )
79
+ .strip()
80
+ .lower()
81
+ )
82
+ if requested != "auto" and visualizer_id != requested:
83
+ return ToolResult(
84
+ content=(
85
+ f"The user fixed the visualization type to '{requested}', but the "
86
+ f"submission used '{visualizer_id}'. Regenerate it as '{requested}'."
87
+ ),
88
+ success=False,
89
+ )
90
+ plugin = registry.get(visualizer_id)
91
+ if plugin is None or not plugin.manifest.agentic:
92
+ available = ", ".join(item.manifest.id for item in registry.agentic())
93
+ return ToolResult(
94
+ content=f"Visualizer '{visualizer_id}' is unavailable. Available: {available}",
95
+ success=False,
96
+ )
97
+
98
+ ok, data, error = plugin.validate_payload(str(kwargs.get("payload") or ""))
99
+ if not ok:
100
+ return ToolResult(
101
+ content=(
102
+ f"{plugin.manifest.display_name} payload validation failed: {error}. "
103
+ "Repair the concrete issue and submit the complete payload again."
104
+ ),
105
+ success=False,
106
+ metadata={"visualizer": visualizer_id, "validation_error": error},
107
+ )
108
+
109
+ entry_url = ""
110
+ if plugin.manifest.render_target == "iframe":
111
+ entry_url = (
112
+ f"/api/visualizers/{plugin.manifest.id}/assets/{plugin.manifest.renderer_entry}"
113
+ )
114
+ envelope = VisualizationEnvelope(
115
+ render_type=plugin.manifest.id,
116
+ renderer=RendererRef(
117
+ id=plugin.manifest.id,
118
+ version=plugin.manifest.version,
119
+ target=plugin.manifest.render_target,
120
+ native_renderer=plugin.manifest.native_renderer,
121
+ entry_url=entry_url,
122
+ ),
123
+ payload=VisualizationPayload(format=plugin.manifest.payload_format, data=data),
124
+ presentation=VisualizationPresentation(
125
+ title=str(kwargs.get("title") or "").strip()[:160],
126
+ description=str(kwargs.get("description") or "").strip()[:1000],
127
+ alt_text=str(kwargs.get("alt_text") or "").strip()[:2000],
128
+ ),
129
+ interaction=VisualizationInteraction(
130
+ events=["prompt", "resize"] if plugin.manifest.render_target == "iframe" else [],
131
+ ),
132
+ fallback={"renderer": "svg"} if visualizer_id != "svg" else {},
133
+ )
134
+ context.metadata[VISUALIZATION_RESULT_KEY] = envelope.model_dump(mode="json")
135
+ return ToolResult(
136
+ content=(
137
+ f"Visualization accepted as {visualizer_id}. The canvas payload is committed. "
138
+ "Finish without repeating the payload."
139
+ ),
140
+ metadata={
141
+ "visualizer": visualizer_id,
142
+ "schema_version": envelope.schema_version,
143
+ "visualization_submitted": True,
144
+ },
145
+ )
146
+
147
+
148
+ VISUALIZER_TOOL_TYPES: tuple[type[BaseTool], ...] = (SubmitVisualizationTool,)
149
+
150
+ __all__ = ["SubmitVisualizationTool", "VISUALIZER_TOOL_TYPES"]
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: deeptutor-visualize
3
+ Version: 1.7.0
4
+ Summary: DeepTutor visualize module
5
+ Requires-Python: <3.15,>=3.11
6
+ Requires-Dist: deeptutor==1.7.0
@@ -0,0 +1,30 @@
1
+ deeptutor/agents/visualize/__init__.py,sha256=hgFc67Db_sGGPEzL_hKrtKzJdWnFJv0Pm2yHCNgEDwM,111
2
+ deeptutor/agents/visualize/capability.py,sha256=ywnNj0HkSHft0uMVg_fDIpU8pMqgZOTRr_hQ22RN6DI,24367
3
+ deeptutor/agents/visualize/models.py,sha256=oYBcLQ5LKpwiDbFEKrBL5X11WqJywHfD-WLzueZiu78,4127
4
+ deeptutor/agents/visualize/pipeline.py,sha256=6a5he396SfhD2fQokCuskjkEm_bWJYcSL6rSC50ffRM,2566
5
+ deeptutor/agents/visualize/utils.py,sha256=jiSJEOsHuL0tXzlUqL31pMjfFTcx7p35lTwN5yxvqtM,7641
6
+ deeptutor/agents/visualize/agents/__init__.py,sha256=4abGfLiEp1bPdGLUZcJo6_DwBmdE1uK4nbZ1LCIeZRI,273
7
+ deeptutor/agents/visualize/agents/analysis_agent.py,sha256=7ahORxHmEZMSyagys2FYOaTerblNZ8s2AYTSXij3dCE,4123
8
+ deeptutor/agents/visualize/agents/code_generator_agent.py,sha256=MuiuIOQ69hMOUsrflfqcxBwnpK83910CMzYCl_qP8g0,4761
9
+ deeptutor/agents/visualize/agents/review_agent.py,sha256=d4IcG7Kae2eu2N9Gc4Xp1540xU7i-p6-2muSiTWv1D4,2540
10
+ deeptutor/agents/visualize/prompts/en/analysis_agent.yaml,sha256=4dJECXu8OnokZ7Gi90carJPOwH7ilx_qBp0NTaHfooI,6621
11
+ deeptutor/agents/visualize/prompts/en/code_generator_agent.yaml,sha256=TBM9PJlVDOCvmBsMgIEcxEYUx0HdpAJZOBL17RaypzY,10791
12
+ deeptutor/agents/visualize/prompts/en/review_agent.yaml,sha256=KMwfsWNXebxqFFqysQwpBKxbzutHWq-r3a-cnArIFjU,1292
13
+ deeptutor/agents/visualize/prompts/en/visualize.yaml,sha256=bGOGEgS9FOSIVimoDSw1ZijPW_9V8yJWKkevSSkSSIs,1523
14
+ deeptutor/agents/visualize/prompts/zh/analysis_agent.yaml,sha256=k6-UBslQSpsS8sLPMMjpzFmJ8EdwJhqo1riqBgFBzyM,6497
15
+ deeptutor/agents/visualize/prompts/zh/code_generator_agent.yaml,sha256=lc_0a87O3sd95eeGwouVG9LaHkxJLsuJMDolG69YaiE,10472
16
+ deeptutor/agents/visualize/prompts/zh/review_agent.yaml,sha256=iIHk5-Tsx-s9e_eNx6bDLsGo8I7qy3KsjGM9MrAAN1E,1254
17
+ deeptutor/agents/visualize/prompts/zh/visualize.yaml,sha256=okdn4tGDJ0T6T_kqzrzIO8CUxMvdtQ8pY9rwp7K7GCI,1448
18
+ deeptutor/api/routers/visualizers.py,sha256=QsfCfQrnB9I4J6xMEbyT0lRQNpF2VswSFzDknxkM47A,5014
19
+ deeptutor/visualizers/README.md,sha256=v_bIkyj-DGDzXc3Q5IngvZvuwuRjpzj3CnPeYk97GS0,2092
20
+ deeptutor/visualizers/__init__.py,sha256=xe93oZOF4hHymbTSyBgFLgyhn1zeR5ChC9ZMVmh8XmE,508
21
+ deeptutor/visualizers/builtin.py,sha256=WV8QwxpyXfTa-rUQG8wT0H5im5GlV_h6MYGVHkKPBR4,15659
22
+ deeptutor/visualizers/loop_capability.py,sha256=q15sAs7dKdQQTMJyXV9u324L_7uWRTTpC-78G8X61S0,5119
23
+ deeptutor/visualizers/protocol.py,sha256=OZLX03JXfHeMDXiA4mp82m5k2zy1-U1X0aQZTRs7liE,7949
24
+ deeptutor/visualizers/registry.py,sha256=z2TBoc4yruYX7Iy_IB7Gw_4v53rwjzH9-7UgHy7assI,6390
25
+ deeptutor/visualizers/store.py,sha256=fcvZ_RC7Av4RG8A8-ZcKPLAuIIQlCJEbaTqTvfjk2RA,11135
26
+ deeptutor/visualizers/tool.py,sha256=YyaYD64-g7ffZGfKNIXh4KnF1hOnIO1Xalf1BVzbgB0,6163
27
+ deeptutor_visualize-1.7.0.dist-info/METADATA,sha256=bJpoH4hV__xz-zM51UqvxkPiqsF19eFImv8daLdyzXY,161
28
+ deeptutor_visualize-1.7.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
29
+ deeptutor_visualize-1.7.0.dist-info/top_level.txt,sha256=hnSHUG_vphMnHpT-DbMqcemCKadJ24laFGAWlovG2xM,10
30
+ deeptutor_visualize-1.7.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ deeptutor