sqlsaber-viz 0.1.1__py3-none-any.whl → 0.2.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.
- sqlsaber_viz/prompts.py +7 -8
- sqlsaber_viz/renderers/plotext_renderer.py +3 -1
- sqlsaber_viz/spec_agent.py +5 -1
- sqlsaber_viz/tools.py +15 -1
- {sqlsaber_viz-0.1.1.dist-info → sqlsaber_viz-0.2.0.dist-info}/METADATA +2 -2
- {sqlsaber_viz-0.1.1.dist-info → sqlsaber_viz-0.2.0.dist-info}/RECORD +8 -8
- {sqlsaber_viz-0.1.1.dist-info → sqlsaber_viz-0.2.0.dist-info}/WHEEL +0 -0
- {sqlsaber_viz-0.1.1.dist-info → sqlsaber_viz-0.2.0.dist-info}/entry_points.txt +0 -0
sqlsaber_viz/prompts.py
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
VIZ_SYSTEM_PROMPT = """You are a visualization spec generator. Given a user's request and data summary, generate a valid JSON visualization spec.
|
|
4
4
|
|
|
5
5
|
## Workflow
|
|
6
|
-
1. Decide the appropriate chart type based on the request and data
|
|
6
|
+
1. Decide the appropriate chart type based on the request and data. To see all available chart types, call `get_available_chart_types`
|
|
7
7
|
2. Call `get_vizspec_template` with the chart type and file to get the correct spec structure
|
|
8
8
|
3. Fill in the template with actual column names from the provided data summary
|
|
9
9
|
4. Return ONLY the final JSON spec (no explanations, no markdown code blocks)
|
|
10
10
|
|
|
11
|
-
## Chart Type Selection
|
|
11
|
+
## Example Chart Type Selection
|
|
12
12
|
- Comparing categories → bar
|
|
13
13
|
- Comparing categories across series → bar with encoding.series
|
|
14
14
|
- Trend over time → line
|
|
@@ -22,10 +22,9 @@ VIZ_SYSTEM_PROMPT = """You are a visualization spec generator. Given a user's re
|
|
|
22
22
|
- {"filter": {"field": "col", "op": "!=", "value": null}} - Filter rows
|
|
23
23
|
|
|
24
24
|
## Rules
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
6. Title should describe what the chart shows
|
|
25
|
+
- Use ONLY columns that exist in the provided data summary
|
|
26
|
+
- Match field types: category columns for x in bar charts, numeric columns for y
|
|
27
|
+
- Add limit transform for bar charts to avoid overcrowding (10-20 bars max)
|
|
28
|
+
- Sort bar charts by y value descending for better readability
|
|
29
|
+
- Title should describe what the chart shows
|
|
31
30
|
"""
|
|
@@ -205,7 +205,9 @@ class PlotextRenderer:
|
|
|
205
205
|
plt.box(labels, data)
|
|
206
206
|
return None
|
|
207
207
|
|
|
208
|
-
def _render_histogram(
|
|
208
|
+
def _render_histogram(
|
|
209
|
+
self, chart: HistogramChart, rows: list[dict], plt
|
|
210
|
+
) -> str | None:
|
|
209
211
|
field = chart.histogram.field
|
|
210
212
|
bins = chart.histogram.bins
|
|
211
213
|
|
sqlsaber_viz/spec_agent.py
CHANGED
|
@@ -24,7 +24,11 @@ class SpecAgent:
|
|
|
24
24
|
self.agent = self._build_agent()
|
|
25
25
|
|
|
26
26
|
def _build_agent(self):
|
|
27
|
-
model_name =
|
|
27
|
+
model_name = (
|
|
28
|
+
self._model_name_override
|
|
29
|
+
or self.config.model.get_subagent_model("viz")
|
|
30
|
+
or self.config.model.name
|
|
31
|
+
)
|
|
28
32
|
model_name_only = (
|
|
29
33
|
model_name.split(":", 1)[1] if ":" in model_name else model_name
|
|
30
34
|
)
|
sqlsaber_viz/tools.py
CHANGED
|
@@ -39,6 +39,18 @@ class VizTool(Tool):
|
|
|
39
39
|
self._last_rows: list[dict] | None = None
|
|
40
40
|
self._last_file: str | None = None
|
|
41
41
|
self._replay_messages: list | None = None
|
|
42
|
+
self._viz_model_name: str | None = None
|
|
43
|
+
self._viz_api_key: str | None = None
|
|
44
|
+
|
|
45
|
+
def set_viz_model(self, model_name: str | None, api_key: str | None = None) -> None:
|
|
46
|
+
"""Set the model used by the internal SpecAgent for viz generation.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
model_name: Model override (format: 'provider:model'). None to use default.
|
|
50
|
+
api_key: Optional API key for the model provider.
|
|
51
|
+
"""
|
|
52
|
+
self._viz_model_name = model_name
|
|
53
|
+
self._viz_api_key = api_key
|
|
42
54
|
|
|
43
55
|
def set_replay_messages(self, messages: list) -> None:
|
|
44
56
|
"""Set message history for replay scenarios (e.g., threads show)."""
|
|
@@ -87,7 +99,9 @@ class VizTool(Tool):
|
|
|
87
99
|
self._last_rows = rows
|
|
88
100
|
self._last_file = file
|
|
89
101
|
|
|
90
|
-
agent = _get_spec_agent_cls()(
|
|
102
|
+
agent = _get_spec_agent_cls()(
|
|
103
|
+
model_name=self._viz_model_name, api_key=self._viz_api_key
|
|
104
|
+
)
|
|
91
105
|
|
|
92
106
|
try:
|
|
93
107
|
spec = await asyncio.wait_for(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlsaber-viz
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: SQLsaber terminal visualization plugin
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Requires-Dist: plotext>=5.3.0
|
|
7
|
-
Requires-Dist: sqlsaber>=0.
|
|
7
|
+
Requires-Dist: sqlsaber>=0.55.1
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
|
|
10
10
|
# SQLSaber Visualization Plugin
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
sqlsaber_viz/__init__.py,sha256=HdXfKzS8O7f1qD1nQo9XBPIB5Y6NvIroWmlaulqdvDs,394
|
|
2
2
|
sqlsaber_viz/data_loader.py,sha256=mTFGCd6GZP_9KK110gupKumJQYsg0QoHVGXeqBefYbY,4380
|
|
3
|
-
sqlsaber_viz/prompts.py,sha256=
|
|
3
|
+
sqlsaber_viz/prompts.py,sha256=OP8f22RSNUWSsJm69oVnP4ZSRG2qmuBxXXuW5ggc5n4,1506
|
|
4
4
|
sqlsaber_viz/spec.py,sha256=_zgUBrHPrjztnyECRZycLps1KeEiLn29x9B0fSdqf10,2923
|
|
5
|
-
sqlsaber_viz/spec_agent.py,sha256=
|
|
5
|
+
sqlsaber_viz/spec_agent.py,sha256=RuU6PUZZaRduzJyncl4Vm3bFfIvAcDH6UwxH9gRGz8w,4789
|
|
6
6
|
sqlsaber_viz/templates.py,sha256=8WDYYVIjEDmKGUo9VPuv_vOOoieqnqGLl39hQpGEWL0,5022
|
|
7
|
-
sqlsaber_viz/tools.py,sha256=
|
|
7
|
+
sqlsaber_viz/tools.py,sha256=Q36tnDuxWsNmMVv79rkhUpO8rv9QvqWLoYmPNShNf4o,8350
|
|
8
8
|
sqlsaber_viz/transforms.py,sha256=I_PxG4fy1ckdwC_9in3KVEa9cAQ9oLmq113eEGmvLEk,4440
|
|
9
9
|
sqlsaber_viz/renderers/__init__.py,sha256=oIDE7QqaulKVN_yVKXqERuPskS-Pvxa2ILk234JbkIs,174
|
|
10
10
|
sqlsaber_viz/renderers/base.py,sha256=V-8dCvgvE1AMpVlwOPRxnNwqumUbjlZmwMr-KpculyI,312
|
|
11
11
|
sqlsaber_viz/renderers/html_renderer.py,sha256=f48JyfpcYIcnwCb_zmi9HlWflir94OOMuSVgi8PQhPA,367
|
|
12
|
-
sqlsaber_viz/renderers/plotext_renderer.py,sha256=
|
|
13
|
-
sqlsaber_viz-0.
|
|
14
|
-
sqlsaber_viz-0.
|
|
15
|
-
sqlsaber_viz-0.
|
|
16
|
-
sqlsaber_viz-0.
|
|
12
|
+
sqlsaber_viz/renderers/plotext_renderer.py,sha256=ipLHJw35Xq-mONfshzz30Ns6EHsnhalhxMmmXiSxdP4,13385
|
|
13
|
+
sqlsaber_viz-0.2.0.dist-info/METADATA,sha256=eO-WEqJ091AibjUHQ1HgJopRIB7ILYg8wjRBpDNmr2k,432
|
|
14
|
+
sqlsaber_viz-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
15
|
+
sqlsaber_viz-0.2.0.dist-info/entry_points.txt,sha256=us67FM9sQiA3XG-UxYbHI9GAKQB5Xpqe_STfQtKEWys,51
|
|
16
|
+
sqlsaber_viz-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|