holoviz-mcp 0.4.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.
- holoviz_mcp/__init__.py +18 -0
- holoviz_mcp/apps/__init__.py +1 -0
- holoviz_mcp/apps/configuration_viewer.py +116 -0
- holoviz_mcp/apps/holoviz_get_best_practices.py +173 -0
- holoviz_mcp/apps/holoviz_search.py +319 -0
- holoviz_mcp/apps/hvplot_get_docstring.py +255 -0
- holoviz_mcp/apps/hvplot_get_signature.py +252 -0
- holoviz_mcp/apps/hvplot_list_plot_types.py +83 -0
- holoviz_mcp/apps/panel_get_component.py +496 -0
- holoviz_mcp/apps/panel_get_component_parameters.py +467 -0
- holoviz_mcp/apps/panel_list_components.py +311 -0
- holoviz_mcp/apps/panel_list_packages.py +71 -0
- holoviz_mcp/apps/panel_search_components.py +312 -0
- holoviz_mcp/cli.py +75 -0
- holoviz_mcp/client.py +94 -0
- holoviz_mcp/config/__init__.py +29 -0
- holoviz_mcp/config/config.yaml +178 -0
- holoviz_mcp/config/loader.py +316 -0
- holoviz_mcp/config/models.py +208 -0
- holoviz_mcp/config/resources/best-practices/holoviews.md +423 -0
- holoviz_mcp/config/resources/best-practices/hvplot.md +465 -0
- holoviz_mcp/config/resources/best-practices/panel-material-ui.md +318 -0
- holoviz_mcp/config/resources/best-practices/panel.md +562 -0
- holoviz_mcp/config/schema.json +228 -0
- holoviz_mcp/holoviz_mcp/__init__.py +1 -0
- holoviz_mcp/holoviz_mcp/data.py +970 -0
- holoviz_mcp/holoviz_mcp/models.py +21 -0
- holoviz_mcp/holoviz_mcp/pages_design.md +407 -0
- holoviz_mcp/holoviz_mcp/server.py +220 -0
- holoviz_mcp/hvplot_mcp/__init__.py +1 -0
- holoviz_mcp/hvplot_mcp/server.py +146 -0
- holoviz_mcp/panel_mcp/__init__.py +17 -0
- holoviz_mcp/panel_mcp/data.py +319 -0
- holoviz_mcp/panel_mcp/models.py +124 -0
- holoviz_mcp/panel_mcp/server.py +443 -0
- holoviz_mcp/py.typed +0 -0
- holoviz_mcp/serve.py +36 -0
- holoviz_mcp/server.py +86 -0
- holoviz_mcp/shared/__init__.py +1 -0
- holoviz_mcp/shared/extract_tools.py +74 -0
- holoviz_mcp/thumbnails/configuration_viewer.png +0 -0
- holoviz_mcp/thumbnails/holoviz_get_best_practices.png +0 -0
- holoviz_mcp/thumbnails/holoviz_search.png +0 -0
- holoviz_mcp/thumbnails/hvplot_get_docstring.png +0 -0
- holoviz_mcp/thumbnails/hvplot_get_signature.png +0 -0
- holoviz_mcp/thumbnails/hvplot_list_plot_types.png +0 -0
- holoviz_mcp/thumbnails/panel_get_component.png +0 -0
- holoviz_mcp/thumbnails/panel_get_component_parameters.png +0 -0
- holoviz_mcp/thumbnails/panel_list_components.png +0 -0
- holoviz_mcp/thumbnails/panel_list_packages.png +0 -0
- holoviz_mcp/thumbnails/panel_search_components.png +0 -0
- holoviz_mcp-0.4.0.dist-info/METADATA +216 -0
- holoviz_mcp-0.4.0.dist-info/RECORD +56 -0
- holoviz_mcp-0.4.0.dist-info/WHEEL +4 -0
- holoviz_mcp-0.4.0.dist-info/entry_points.txt +2 -0
- holoviz_mcp-0.4.0.dist-info/licenses/LICENSE.txt +30 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"""An app to retrieve hvPlot docstring documentation for plot types.
|
|
2
|
+
|
|
3
|
+
An interactive version of the holoviz_mcp.hvplot_mcp.server.get_docstring tool.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import panel as pn
|
|
7
|
+
import panel_material_ui as pmui
|
|
8
|
+
import param
|
|
9
|
+
|
|
10
|
+
from holoviz_mcp.client import call_tool
|
|
11
|
+
|
|
12
|
+
pn.extension()
|
|
13
|
+
|
|
14
|
+
pn.pane.Markdown.disable_anchors = True
|
|
15
|
+
|
|
16
|
+
ABOUT = """
|
|
17
|
+
## hvPlot Get Docstring Tool
|
|
18
|
+
|
|
19
|
+
Get comprehensive documentation for any hvPlot plot type, equivalent to calling `hvplot.help(plot_type)` in Python.
|
|
20
|
+
|
|
21
|
+
### How to Use This Tool
|
|
22
|
+
|
|
23
|
+
1. **Plot Type**: Select the type of plot you want documentation for (e.g., "line", "scatter", "bar")
|
|
24
|
+
2. **Configuration Options**: Adjust what content to include:
|
|
25
|
+
- **Include Docstring**: Main documentation and examples
|
|
26
|
+
- **Include Generic Options**: Options shared by all plot types
|
|
27
|
+
- **Style Backend**: Get options specific to matplotlib, bokeh, plotly, or auto-detect
|
|
28
|
+
|
|
29
|
+
### Use Cases
|
|
30
|
+
|
|
31
|
+
**Learn hvPlot plotting**:
|
|
32
|
+
|
|
33
|
+
- Understand available parameters for customization
|
|
34
|
+
- Explore examples and usage patterns
|
|
35
|
+
- Compare options across different backends
|
|
36
|
+
- Get quick reference while coding
|
|
37
|
+
|
|
38
|
+
**Plot Development**:
|
|
39
|
+
|
|
40
|
+
- Check parameter names and types before coding
|
|
41
|
+
- Discover advanced customization options
|
|
42
|
+
- Learn best practices from examples
|
|
43
|
+
- Understand backend differences
|
|
44
|
+
|
|
45
|
+
### Configuration Options
|
|
46
|
+
|
|
47
|
+
- **Plot Type**: Choose from all available hvPlot plot types
|
|
48
|
+
- **Include Docstring**: Toggle main documentation (default: True)
|
|
49
|
+
- **Include Generic Options**: Toggle shared plotting options (default: True)
|
|
50
|
+
- **Style Backend**: Select specific backend or auto-detect (default: auto)
|
|
51
|
+
|
|
52
|
+
### Learn More
|
|
53
|
+
|
|
54
|
+
For more information visit: [hvPlot Documentation](https://hvplot.holoviz.org/) and [HoloViz MCP](https://marcskovmadsen.github.io/holoviz-mcp/).
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class GetDocstringConfiguration(param.Parameterized):
|
|
59
|
+
"""Configuration for hvPlot get_docstring tool."""
|
|
60
|
+
|
|
61
|
+
plot_type = param.Selector(default="line", objects=["line"], label="Plot Type")
|
|
62
|
+
docstring = param.Boolean(default=True, label="Include Docstring")
|
|
63
|
+
generic = param.Boolean(default=True, label="Include Generic Options")
|
|
64
|
+
style = param.Selector(default=True, objects=[True, "matplotlib", "bokeh", "plotly"], label="Style Backend")
|
|
65
|
+
|
|
66
|
+
result = param.String(default="", doc="Docstring result")
|
|
67
|
+
loading = param.Boolean(default=False, doc="Loading state")
|
|
68
|
+
error_message = param.String(default="", doc="Error message if request fails")
|
|
69
|
+
|
|
70
|
+
def __init__(self, **params):
|
|
71
|
+
super().__init__(**params)
|
|
72
|
+
if pn.state.location:
|
|
73
|
+
pn.state.location.sync(self, ["plot_type", "docstring", "generic", "style"])
|
|
74
|
+
# Initialize with available plot types
|
|
75
|
+
pn.state.execute(self._update_plot_types)
|
|
76
|
+
# Load default docstring on startup
|
|
77
|
+
pn.state.execute(self._update_result)
|
|
78
|
+
|
|
79
|
+
async def _update_plot_types(self):
|
|
80
|
+
"""Update the available plot types."""
|
|
81
|
+
try:
|
|
82
|
+
result = await call_tool("hvplot_list_plot_types", {})
|
|
83
|
+
plot_types = sorted(result.data)
|
|
84
|
+
self.param.plot_type.objects = plot_types
|
|
85
|
+
except Exception as e:
|
|
86
|
+
self.error_message = f"Failed to load plot types: {str(e)}"
|
|
87
|
+
|
|
88
|
+
@param.depends("plot_type", "docstring", "generic", "style", watch=True)
|
|
89
|
+
async def _update_result(self):
|
|
90
|
+
"""Execute tool and update result."""
|
|
91
|
+
self.loading = True
|
|
92
|
+
self.error_message = ""
|
|
93
|
+
self.result = ""
|
|
94
|
+
|
|
95
|
+
params = {"plot_type": self.plot_type, "docstring": self.docstring, "generic": self.generic, "style": self.style}
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
result = await call_tool("hvplot_get_docstring", params)
|
|
99
|
+
if result and hasattr(result, "structured_content"):
|
|
100
|
+
if result.data:
|
|
101
|
+
self.result = result.data.replace("``", "`")
|
|
102
|
+
else:
|
|
103
|
+
self.error_message = "No docstring returned for the specified plot type"
|
|
104
|
+
else:
|
|
105
|
+
self.error_message = "Request returned no data"
|
|
106
|
+
|
|
107
|
+
except Exception as e:
|
|
108
|
+
error_str = str(e)
|
|
109
|
+
self.error_message = f"Request failed: {error_str}"
|
|
110
|
+
finally:
|
|
111
|
+
self.loading = False
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class DocstringViewer(pn.viewable.Viewer):
|
|
115
|
+
"""Viewer for displaying hvPlot docstring."""
|
|
116
|
+
|
|
117
|
+
result = param.String(default="", allow_refs=True, doc="Docstring content")
|
|
118
|
+
|
|
119
|
+
def __init__(self, **params):
|
|
120
|
+
super().__init__(**params)
|
|
121
|
+
|
|
122
|
+
raw_view = pn.pane.Str(
|
|
123
|
+
self.param.result,
|
|
124
|
+
name="Raw Response",
|
|
125
|
+
sizing_mode="stretch_width",
|
|
126
|
+
styles={"font-family": "monospace", "white-space": "pre-wrap"},
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
self._layout = raw_view
|
|
130
|
+
|
|
131
|
+
def __panel__(self):
|
|
132
|
+
"""Return the Panel layout."""
|
|
133
|
+
return self._layout
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class HvplotGetDocstringApp(pn.viewable.Viewer):
|
|
137
|
+
"""Main application for retrieving hvPlot docstrings."""
|
|
138
|
+
|
|
139
|
+
title = param.String(default="HoloViz MCP - hvplot_get_docstring Tool Demo")
|
|
140
|
+
|
|
141
|
+
def __init__(self, **params):
|
|
142
|
+
super().__init__(**params)
|
|
143
|
+
|
|
144
|
+
# Create configuration and viewer
|
|
145
|
+
self._config = GetDocstringConfiguration()
|
|
146
|
+
self._docstring_viewer = DocstringViewer(result=self._config.param.result)
|
|
147
|
+
|
|
148
|
+
with pn.config.set(sizing_mode="stretch_width"):
|
|
149
|
+
self._plot_type_select = pmui.Select.from_param(
|
|
150
|
+
self._config.param.plot_type,
|
|
151
|
+
label="Plot Type",
|
|
152
|
+
variant="outlined",
|
|
153
|
+
sx={"width": "100%"},
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
self._docstring_switch = pmui.Switch.from_param(
|
|
157
|
+
self._config.param.docstring,
|
|
158
|
+
label="Include Docstring",
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
self._generic_switch = pmui.Switch.from_param(
|
|
162
|
+
self._config.param.generic,
|
|
163
|
+
label="Include Generic Options",
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
self._style_select = pmui.Select.from_param(
|
|
167
|
+
self._config.param.style,
|
|
168
|
+
label="Style Backend",
|
|
169
|
+
variant="outlined",
|
|
170
|
+
sx={"width": "100%"},
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Status indicators
|
|
174
|
+
self._status_pane = pn.pane.Markdown(self._status_text, sizing_mode="stretch_width")
|
|
175
|
+
self._error_pane = pmui.Alert(
|
|
176
|
+
self._error_text,
|
|
177
|
+
alert_type="error",
|
|
178
|
+
visible=pn.rx(bool)(self._config.param.error_message),
|
|
179
|
+
sizing_mode="stretch_width",
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
# Quick access buttons for common plot types
|
|
183
|
+
# Create static layout structure
|
|
184
|
+
self._sidebar = pn.Column(
|
|
185
|
+
pmui.Typography("## Documentation Lookup", variant="h6"),
|
|
186
|
+
self._plot_type_select,
|
|
187
|
+
pmui.Typography("### Options", variant="subtitle2", margin=(15, 0, 5, 0)),
|
|
188
|
+
self._docstring_switch,
|
|
189
|
+
self._generic_switch,
|
|
190
|
+
self._style_select,
|
|
191
|
+
self._error_pane,
|
|
192
|
+
self._status_pane,
|
|
193
|
+
sizing_mode="stretch_width",
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
self._main = pmui.Container(self._docstring_viewer, width_option="xl", margin=10)
|
|
197
|
+
|
|
198
|
+
@param.depends("_config.loading", "_config.result")
|
|
199
|
+
def _status_text(self):
|
|
200
|
+
"""Generate status message."""
|
|
201
|
+
if self._config.loading:
|
|
202
|
+
return "_Loading docstring..._"
|
|
203
|
+
elif self._config.result.strip():
|
|
204
|
+
char_count = len(self._config.result)
|
|
205
|
+
plot_type = self._config.plot_type
|
|
206
|
+
return f"_Successfully loaded **{char_count} characters** of documentation for **{plot_type}** plot_"
|
|
207
|
+
return ""
|
|
208
|
+
|
|
209
|
+
@param.depends("_config.error_message")
|
|
210
|
+
def _error_text(self):
|
|
211
|
+
"""Get error message."""
|
|
212
|
+
return self._config.error_message
|
|
213
|
+
|
|
214
|
+
def __panel__(self):
|
|
215
|
+
"""Return the main page layout."""
|
|
216
|
+
with pn.config.set(sizing_mode="stretch_width"):
|
|
217
|
+
# About button and dialog
|
|
218
|
+
about_button = pmui.IconButton(
|
|
219
|
+
label="About",
|
|
220
|
+
icon="info",
|
|
221
|
+
description="Click to learn about the hvPlot Get Docstring Tool.",
|
|
222
|
+
sizing_mode="fixed",
|
|
223
|
+
width=40,
|
|
224
|
+
height=40,
|
|
225
|
+
color="light",
|
|
226
|
+
margin=(10, 0),
|
|
227
|
+
)
|
|
228
|
+
about = pmui.Dialog(ABOUT, close_on_click=True, width=0)
|
|
229
|
+
about_button.js_on_click(args={"about": about}, code="about.data.open = true")
|
|
230
|
+
|
|
231
|
+
# GitHub button
|
|
232
|
+
github_button = pmui.IconButton(
|
|
233
|
+
label="Github",
|
|
234
|
+
icon="star",
|
|
235
|
+
description="Give HoloViz-MCP a star on GitHub",
|
|
236
|
+
sizing_mode="fixed",
|
|
237
|
+
width=40,
|
|
238
|
+
height=40,
|
|
239
|
+
color="light",
|
|
240
|
+
margin=(10, 0),
|
|
241
|
+
href="https://github.com/MarcSkovMadsen/holoviz-mcp",
|
|
242
|
+
target="_blank",
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
return pmui.Page(
|
|
246
|
+
title=self.title,
|
|
247
|
+
site_url="./",
|
|
248
|
+
sidebar=[self._sidebar],
|
|
249
|
+
header=[pn.Row(pn.Spacer(), about_button, github_button, align="end")],
|
|
250
|
+
main=[about, self._main],
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
if pn.state.served:
|
|
255
|
+
HvplotGetDocstringApp().servable()
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"""An app to retrieve hvPlot function signatures for plot types.
|
|
2
|
+
|
|
3
|
+
An interactive version of the holoviz_mcp.hvplot_mcp.server.get_signature tool.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import panel as pn
|
|
7
|
+
import panel_material_ui as pmui
|
|
8
|
+
import param
|
|
9
|
+
|
|
10
|
+
from holoviz_mcp.client import call_tool
|
|
11
|
+
|
|
12
|
+
pn.extension()
|
|
13
|
+
|
|
14
|
+
pn.pane.Markdown.disable_anchors = True
|
|
15
|
+
|
|
16
|
+
ABOUT = """
|
|
17
|
+
## hvPlot Get Signature Tool
|
|
18
|
+
|
|
19
|
+
Get Python function signatures for any hvPlot plot type, showing all accepted parameters and their defaults.
|
|
20
|
+
|
|
21
|
+
### How to Use This Tool
|
|
22
|
+
|
|
23
|
+
1. **Plot Type**: Select the type of plot you want the signature for (e.g., "line", "scatter", "bar")
|
|
24
|
+
2. **Configuration Options**: Adjust signature options:
|
|
25
|
+
- **Style Backend**: Get backend-specific parameters for matplotlib, bokeh, plotly, or auto-detect
|
|
26
|
+
|
|
27
|
+
### Key Features
|
|
28
|
+
|
|
29
|
+
This tool provides **complete function signatures**:
|
|
30
|
+
|
|
31
|
+
- **Parameter lists** with types and default values
|
|
32
|
+
- **Required vs optional** parameter categorization
|
|
33
|
+
- **Backend-specific parameters** (matplotlib, bokeh, plotly)
|
|
34
|
+
|
|
35
|
+
### Use Cases
|
|
36
|
+
|
|
37
|
+
**API Reference**:
|
|
38
|
+
|
|
39
|
+
- Check exact parameter names before coding
|
|
40
|
+
- Explore backend-specific options
|
|
41
|
+
- Compare signatures across backends
|
|
42
|
+
|
|
43
|
+
**Development Workflow**:
|
|
44
|
+
|
|
45
|
+
- Quick parameter lookup while coding
|
|
46
|
+
- Understand function interfaces
|
|
47
|
+
- Validate parameter usage
|
|
48
|
+
- Learn hvPlot API patterns
|
|
49
|
+
|
|
50
|
+
### Example Usage
|
|
51
|
+
|
|
52
|
+
**Backend-specific scatter plot**:
|
|
53
|
+
- Plot Type: `scatter`
|
|
54
|
+
- Style Backend: `bokeh`
|
|
55
|
+
|
|
56
|
+
### Learn More
|
|
57
|
+
|
|
58
|
+
For more information visit: [hvPlot Documentation](https://hvplot.holoviz.org/) and [HoloViz MCP](https://marcskovmadsen.github.io/holoviz-mcp/).
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class GetSignatureConfiguration(param.Parameterized):
|
|
63
|
+
"""Configuration for hvPlot get_signature tool."""
|
|
64
|
+
|
|
65
|
+
plot_type = param.Selector(default="line", objects=["line"], label="Plot Type")
|
|
66
|
+
style = param.Selector(default=True, objects=[True, "matplotlib", "bokeh", "plotly"], label="Style Backend")
|
|
67
|
+
|
|
68
|
+
result = param.String(default="", doc="Function signature result")
|
|
69
|
+
loading = param.Boolean(default=False, doc="Loading state")
|
|
70
|
+
error_message = param.String(default="", doc="Error message if request fails")
|
|
71
|
+
|
|
72
|
+
def __init__(self, **params):
|
|
73
|
+
super().__init__(**params)
|
|
74
|
+
if pn.state.location:
|
|
75
|
+
pn.state.location.sync(self, ["plot_type", "style"])
|
|
76
|
+
# Initialize with available plot types
|
|
77
|
+
pn.state.execute(self._update_plot_types)
|
|
78
|
+
# Load default signature on startup
|
|
79
|
+
pn.state.execute(self._update_result)
|
|
80
|
+
|
|
81
|
+
async def _update_plot_types(self):
|
|
82
|
+
"""Update the available plot types."""
|
|
83
|
+
try:
|
|
84
|
+
result = await call_tool("hvplot_list_plot_types", {})
|
|
85
|
+
plot_types = sorted(result.data)
|
|
86
|
+
self.param.plot_type.objects = plot_types
|
|
87
|
+
except Exception as e:
|
|
88
|
+
self.error_message = f"Failed to load plot types: {str(e)}"
|
|
89
|
+
|
|
90
|
+
@param.depends("plot_type", "style", watch=True)
|
|
91
|
+
async def _update_result(self):
|
|
92
|
+
"""Execute get_signature and update result."""
|
|
93
|
+
self.loading = True
|
|
94
|
+
self.error_message = ""
|
|
95
|
+
self.result = ""
|
|
96
|
+
|
|
97
|
+
params = {"plot_type": self.plot_type, "style": self.style}
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
result = await call_tool("hvplot_get_signature", params)
|
|
101
|
+
if result and hasattr(result, "structured_content"):
|
|
102
|
+
if result.data:
|
|
103
|
+
self.result = result.data.replace("``", "`")
|
|
104
|
+
else:
|
|
105
|
+
self.error_message = "No signature returned for the specified plot type"
|
|
106
|
+
else:
|
|
107
|
+
self.error_message = "Request returned no data"
|
|
108
|
+
|
|
109
|
+
except Exception as e:
|
|
110
|
+
error_str = str(e)
|
|
111
|
+
self.error_message = f"Request failed: {error_str}"
|
|
112
|
+
finally:
|
|
113
|
+
self.loading = False
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class SignatureViewer(pn.viewable.Viewer):
|
|
117
|
+
"""Viewer for displaying hvPlot function signatures."""
|
|
118
|
+
|
|
119
|
+
result = param.String(default="", allow_refs=True, doc="Signature content")
|
|
120
|
+
|
|
121
|
+
def __init__(self, **params):
|
|
122
|
+
super().__init__(**params)
|
|
123
|
+
|
|
124
|
+
# Raw signature content only
|
|
125
|
+
self._layout = pn.pane.Str(
|
|
126
|
+
self.param.result,
|
|
127
|
+
stylesheets=[
|
|
128
|
+
"""
|
|
129
|
+
pre {
|
|
130
|
+
font-family: monospace;
|
|
131
|
+
white-space: pre-wrap;
|
|
132
|
+
word-wrap: break-word;
|
|
133
|
+
word-break: break-all;
|
|
134
|
+
overflow-wrap: break-word;
|
|
135
|
+
}
|
|
136
|
+
"""
|
|
137
|
+
],
|
|
138
|
+
sizing_mode="stretch_width",
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
def __panel__(self):
|
|
142
|
+
"""Return the Panel layout."""
|
|
143
|
+
return self._layout
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class HvplotGetSignatureApp(pn.viewable.Viewer):
|
|
147
|
+
"""Main application for retrieving hvPlot function signatures."""
|
|
148
|
+
|
|
149
|
+
title = param.String(default="HoloViz MCP - hvplot_get_signature Tool Demo")
|
|
150
|
+
|
|
151
|
+
def __init__(self, **params):
|
|
152
|
+
super().__init__(**params)
|
|
153
|
+
|
|
154
|
+
# Create configuration and viewer
|
|
155
|
+
self._config = GetSignatureConfiguration()
|
|
156
|
+
self._signature_viewer = SignatureViewer(result=self._config.param.result)
|
|
157
|
+
|
|
158
|
+
with pn.config.set(sizing_mode="stretch_width"):
|
|
159
|
+
self._plot_type_select = pmui.Select.from_param(
|
|
160
|
+
self._config.param.plot_type,
|
|
161
|
+
label="Plot Type",
|
|
162
|
+
variant="outlined",
|
|
163
|
+
sx={"width": "100%"},
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
self._style_select = pmui.Select.from_param(
|
|
167
|
+
self._config.param.style,
|
|
168
|
+
label="Style Backend",
|
|
169
|
+
variant="outlined",
|
|
170
|
+
sx={"width": "100%"},
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Status indicators
|
|
174
|
+
self._status_pane = pn.pane.Markdown(self._status_text, sizing_mode="stretch_width")
|
|
175
|
+
self._error_pane = pmui.Alert(
|
|
176
|
+
self._error_text,
|
|
177
|
+
alert_type="error",
|
|
178
|
+
visible=pn.rx(lambda msg: bool(msg))(self._config.param.error_message),
|
|
179
|
+
sizing_mode="stretch_width",
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
# Create static layout structure
|
|
183
|
+
self._sidebar = pn.Column(
|
|
184
|
+
pmui.Typography("## Signature Lookup", variant="h6"),
|
|
185
|
+
self._plot_type_select,
|
|
186
|
+
pmui.Typography("### Options", variant="subtitle2", margin=(15, 0, 5, 0)),
|
|
187
|
+
self._style_select,
|
|
188
|
+
self._error_pane,
|
|
189
|
+
self._status_pane,
|
|
190
|
+
sizing_mode="stretch_width",
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
self._main = pmui.Container(self._signature_viewer, width_option="md", margin=10)
|
|
194
|
+
|
|
195
|
+
@param.depends("_config.loading", "_config.result")
|
|
196
|
+
def _status_text(self):
|
|
197
|
+
"""Generate status message."""
|
|
198
|
+
if self._config.loading:
|
|
199
|
+
return "_Loading function signature..._"
|
|
200
|
+
elif self._config.result.strip():
|
|
201
|
+
char_count = len(self._config.result)
|
|
202
|
+
plot_type = self._config.plot_type
|
|
203
|
+
return f"_Successfully loaded **{char_count} characters** of signature for **{plot_type}** plot_"
|
|
204
|
+
return ""
|
|
205
|
+
|
|
206
|
+
@param.depends("_config.error_message")
|
|
207
|
+
def _error_text(self):
|
|
208
|
+
"""Get error message."""
|
|
209
|
+
return self._config.error_message
|
|
210
|
+
|
|
211
|
+
def __panel__(self):
|
|
212
|
+
"""Return the main page layout."""
|
|
213
|
+
with pn.config.set(sizing_mode="stretch_width"):
|
|
214
|
+
# About button and dialog
|
|
215
|
+
about_button = pmui.IconButton(
|
|
216
|
+
label="About",
|
|
217
|
+
icon="info",
|
|
218
|
+
description="Click to learn about the hvPlot Get Signature Tool.",
|
|
219
|
+
sizing_mode="fixed",
|
|
220
|
+
width=40,
|
|
221
|
+
height=40,
|
|
222
|
+
color="light",
|
|
223
|
+
margin=(10, 0),
|
|
224
|
+
)
|
|
225
|
+
about = pmui.Dialog(ABOUT, close_on_click=True, width=0)
|
|
226
|
+
about_button.js_on_click(args={"about": about}, code="about.data.open = true")
|
|
227
|
+
|
|
228
|
+
# GitHub button
|
|
229
|
+
github_button = pmui.IconButton(
|
|
230
|
+
label="Github",
|
|
231
|
+
icon="star",
|
|
232
|
+
description="Give HoloViz-MCP a star on GitHub",
|
|
233
|
+
sizing_mode="fixed",
|
|
234
|
+
width=40,
|
|
235
|
+
height=40,
|
|
236
|
+
color="light",
|
|
237
|
+
margin=(10, 0),
|
|
238
|
+
href="https://github.com/MarcSkovMadsen/holoviz-mcp",
|
|
239
|
+
target="_blank",
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
return pmui.Page(
|
|
243
|
+
title=self.title,
|
|
244
|
+
site_url="./",
|
|
245
|
+
sidebar=[self._sidebar],
|
|
246
|
+
header=[pn.Row(pn.Spacer(), about_button, github_button, align="end")],
|
|
247
|
+
main=[about, self._main],
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
if pn.state.served:
|
|
252
|
+
HvplotGetSignatureApp().servable()
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""An app to demo the usage and responses of the hvplot_list_plot_types tool."""
|
|
2
|
+
|
|
3
|
+
import panel as pn
|
|
4
|
+
import panel_material_ui as pmui
|
|
5
|
+
|
|
6
|
+
from holoviz_mcp.client import call_tool
|
|
7
|
+
|
|
8
|
+
ABOUT = """
|
|
9
|
+
# hvPlot List Plot Types Tool
|
|
10
|
+
|
|
11
|
+
The `hvplot_list_plot_types` tool lists all available hvPlot plot types supported in the current environment.
|
|
12
|
+
|
|
13
|
+
## Purpose
|
|
14
|
+
|
|
15
|
+
Discover what plot types you can generate with hvPlot. These are also called "kinds" in the hvPlot API.
|
|
16
|
+
|
|
17
|
+
## Use Cases
|
|
18
|
+
|
|
19
|
+
- Explore available visualization options before creating plots
|
|
20
|
+
- Understand what plot types are supported in your environment
|
|
21
|
+
- Find the right plot type name to use in `df.hvplot.kind()` or `df.hvplot(kind='...')`
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
A sorted list of all plot type names available in hvPlot.
|
|
26
|
+
|
|
27
|
+
**Examples:** `['area', 'bar', 'box', 'contour', 'line', 'scatter', 'violin', ...]`
|
|
28
|
+
|
|
29
|
+
## Next Steps
|
|
30
|
+
|
|
31
|
+
After discovering plot types with this tool, use:
|
|
32
|
+
|
|
33
|
+
- [`hvplot_get_docstring`](./hvplot_get_docstring) - Get detailed documentation for a specific plot type
|
|
34
|
+
- [`hvplot_get_signature`](./hvplot_get_signature) - Get the function signature for a plot type
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pn.cache
|
|
39
|
+
async def hvplot_list_plot_types() -> list[str]:
|
|
40
|
+
"""Demo the usage and responses of the hvplot_list_plot_types tool."""
|
|
41
|
+
response = await call_tool(
|
|
42
|
+
tool_name="hvplot_list_plot_types",
|
|
43
|
+
parameters={},
|
|
44
|
+
)
|
|
45
|
+
return response.data
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def create_app():
|
|
49
|
+
"""Create the Panel Material UI app for demoing the hvplot_list_plot_types tool."""
|
|
50
|
+
about_button = pmui.IconButton(
|
|
51
|
+
label="About",
|
|
52
|
+
icon="info",
|
|
53
|
+
description="Click to learn about the hvPlot List Plot Types Tool.",
|
|
54
|
+
sizing_mode="fixed",
|
|
55
|
+
color="light",
|
|
56
|
+
margin=(10, 0),
|
|
57
|
+
)
|
|
58
|
+
about = pmui.Dialog(ABOUT, close_on_click=True, width=0)
|
|
59
|
+
about_button.js_on_click(args={"about": about}, code="about.data.open = true")
|
|
60
|
+
|
|
61
|
+
# GitHub button
|
|
62
|
+
github_button = pmui.IconButton(
|
|
63
|
+
label="Github",
|
|
64
|
+
icon="star",
|
|
65
|
+
description="Give HoloViz-MCP a star on GitHub",
|
|
66
|
+
sizing_mode="fixed",
|
|
67
|
+
color="light",
|
|
68
|
+
margin=(10, 0),
|
|
69
|
+
href="https://github.com/MarcSkovMadsen/holoviz-mcp",
|
|
70
|
+
target="_blank",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
main = pmui.Container(about, pn.pane.JSON(hvplot_list_plot_types, theme="dark", depth=3, sizing_mode="stretch_width"))
|
|
74
|
+
|
|
75
|
+
return pmui.Page(
|
|
76
|
+
title="HoloViz-MCP: hvplot_list_plot_types Tool Demo",
|
|
77
|
+
header=[pmui.Row(pn.HSpacer(), about_button, github_button, sizing_mode="stretch_width")],
|
|
78
|
+
main=[main],
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if pn.state.served:
|
|
83
|
+
create_app().servable()
|