sqlsaber-viz 0.1.1__tar.gz → 0.2.0__tar.gz
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-0.2.0/CHANGELOG.md +16 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/PKG-INFO +2 -2
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/pyproject.toml +2 -2
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/prompts.py +7 -8
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/renderers/plotext_renderer.py +3 -1
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/spec_agent.py +5 -1
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/tools.py +15 -1
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/tests/test_data_loader.py +0 -1
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/tests/test_transforms.py +1 -1
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/tests/test_viz_tool.py +4 -3
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/uv.lock +5 -5
- sqlsaber_viz-0.1.1/CHANGELOG.md +0 -8
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/.gitignore +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/README.md +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/pytest.ini +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/__init__.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/data_loader.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/renderers/__init__.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/renderers/base.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/renderers/html_renderer.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/spec.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/templates.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/src/sqlsaber_viz/transforms.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/tests/test_render_plotext.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/tests/test_spec_validation.py +0 -0
- {sqlsaber_viz-0.1.1 → sqlsaber_viz-0.2.0}/tests/test_templates.py +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.0](https://github.com/SarthakJariwala/sqlsaber/compare/sqlsaber-viz-v0.1.1...sqlsaber-viz-v0.2.0) (2026-02-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* allow overriding subagent model configuration via cli ([#118](https://github.com/SarthakJariwala/sqlsaber/issues/118)) ([ac31f8d](https://github.com/SarthakJariwala/sqlsaber/commit/ac31f8d71d328ab956f1f399a71e38ff5f769f7e))
|
|
9
|
+
* visualization model override support via api and prompt improvements ([35a506b](https://github.com/SarthakJariwala/sqlsaber/commit/35a506b23337dd64f8f20606e7e547755eae6f21))
|
|
10
|
+
|
|
11
|
+
## [0.1.1](https://github.com/SarthakJariwala/sqlsaber/compare/sqlsaber-viz-v0.1.0...sqlsaber-viz-v0.1.1) (2026-02-05)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* first plugins release ([bd1a5b5](https://github.com/SarthakJariwala/sqlsaber/commit/bd1a5b5079d6eaff2a52bdf4b8812d54ea8c2783))
|
|
@@ -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,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sqlsaber-viz"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "SQLsaber terminal visualization plugin"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
|
-
dependencies = ["sqlsaber>=0.
|
|
7
|
+
dependencies = ["sqlsaber>=0.55.1", "plotext>=5.3.0"]
|
|
8
8
|
|
|
9
9
|
[project.entry-points."sqlsaber.tools"]
|
|
10
10
|
viz = "sqlsaber_viz:register_tools"
|
|
@@ -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
|
|
|
@@ -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
|
)
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
"""Transform pipeline tests."""
|
|
2
2
|
|
|
3
|
-
from sqlsaber_viz.spec import FilterConfig,
|
|
3
|
+
from sqlsaber_viz.spec import FilterConfig, LimitTransform, SortItem, SortTransform
|
|
4
4
|
from sqlsaber_viz.transforms import apply_filter, apply_sort, apply_transforms
|
|
5
5
|
|
|
6
6
|
|
|
@@ -7,7 +7,6 @@ from types import SimpleNamespace
|
|
|
7
7
|
import pytest
|
|
8
8
|
from rich.console import Console
|
|
9
9
|
|
|
10
|
-
import sqlsaber.tools # Ensure plugin discovery runs before importing viz tool.
|
|
11
10
|
import sqlsaber_viz.tools as tools
|
|
12
11
|
from sqlsaber_viz.spec import VizSpec
|
|
13
12
|
from sqlsaber_viz.tools import VizTool
|
|
@@ -24,7 +23,7 @@ def _make_ctx(payload: dict, tool_call_id: str) -> SimpleNamespace:
|
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
class DummyAgent:
|
|
27
|
-
def __init__(self):
|
|
26
|
+
def __init__(self, model_name: str | None = None, api_key: str | None = None):
|
|
28
27
|
pass
|
|
29
28
|
|
|
30
29
|
async def generate_spec(
|
|
@@ -52,7 +51,9 @@ class DummyAgent:
|
|
|
52
51
|
|
|
53
52
|
|
|
54
53
|
@pytest.mark.asyncio
|
|
55
|
-
async def test_viz_tool_execute_adds_bar_defaults(
|
|
54
|
+
async def test_viz_tool_execute_adds_bar_defaults(
|
|
55
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
56
|
+
) -> None:
|
|
56
57
|
monkeypatch.setattr(tools, "_get_spec_agent_cls", lambda: DummyAgent)
|
|
57
58
|
|
|
58
59
|
payload = {
|
|
@@ -2866,7 +2866,7 @@ wheels = [
|
|
|
2866
2866
|
|
|
2867
2867
|
[[package]]
|
|
2868
2868
|
name = "sqlsaber"
|
|
2869
|
-
version = "0.
|
|
2869
|
+
version = "0.55.1"
|
|
2870
2870
|
source = { registry = "https://pypi.org/simple" }
|
|
2871
2871
|
dependencies = [
|
|
2872
2872
|
{ name = "aiomysql" },
|
|
@@ -2886,14 +2886,14 @@ dependencies = [
|
|
|
2886
2886
|
{ name = "structlog" },
|
|
2887
2887
|
{ name = "tabulate" },
|
|
2888
2888
|
]
|
|
2889
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
2889
|
+
sdist = { url = "https://files.pythonhosted.org/packages/a8/17/374b0751a61ad7c333770848e045ebbaaeddcfbba160faa8569ef64f9e92/sqlsaber-0.55.1.tar.gz", hash = "sha256:4de35461aa184de3a8eb6c3fab8460e6645c4449ba9d2f03eb5d3922727c6433", size = 8328110, upload-time = "2026-02-05T01:01:44.721Z" }
|
|
2890
2890
|
wheels = [
|
|
2891
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
2891
|
+
{ url = "https://files.pythonhosted.org/packages/5e/a7/565f6c39819cf022cd8e4bb887f3b76ffff22c32450dd8f97b424d1b37cb/sqlsaber-0.55.1-py3-none-any.whl", hash = "sha256:43abeb89cf2b78ce12b419316eeea55b60805d7e91298bf00b2b39c289dc02af", size = 138128, upload-time = "2026-02-05T01:01:46.735Z" },
|
|
2892
2892
|
]
|
|
2893
2893
|
|
|
2894
2894
|
[[package]]
|
|
2895
2895
|
name = "sqlsaber-viz"
|
|
2896
|
-
version = "0.
|
|
2896
|
+
version = "0.2.0"
|
|
2897
2897
|
source = { editable = "." }
|
|
2898
2898
|
dependencies = [
|
|
2899
2899
|
{ name = "plotext" },
|
|
@@ -2909,7 +2909,7 @@ dev = [
|
|
|
2909
2909
|
[package.metadata]
|
|
2910
2910
|
requires-dist = [
|
|
2911
2911
|
{ name = "plotext", specifier = ">=5.3.0" },
|
|
2912
|
-
{ name = "sqlsaber", specifier = ">=0.
|
|
2912
|
+
{ name = "sqlsaber", specifier = ">=0.55.1" },
|
|
2913
2913
|
]
|
|
2914
2914
|
|
|
2915
2915
|
[package.metadata.requires-dev]
|
sqlsaber_viz-0.1.1/CHANGELOG.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [0.1.1](https://github.com/SarthakJariwala/sqlsaber/compare/sqlsaber-viz-v0.1.0...sqlsaber-viz-v0.1.1) (2026-02-05)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Features
|
|
7
|
-
|
|
8
|
-
* first plugins release ([bd1a5b5](https://github.com/SarthakJariwala/sqlsaber/commit/bd1a5b5079d6eaff2a52bdf4b8812d54ea8c2783))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|