-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathhv_list.py
More file actions
98 lines (73 loc) · 2.79 KB
/
Copy pathhv_list.py
File metadata and controls
98 lines (73 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""An app to demo the usage and responses of the hv_list tool."""
import panel as pn
import panel_material_ui as pmui
from holoviz_mcp.client import call_tool
ABOUT = """
# HoloViews List Elements Tool
The `hv_list` tool lists all available HoloViews visualization elements.
## Purpose
Discover what visualization elements you can create with HoloViews. Elements are the
building blocks for composing complex visualizations.
## Use Cases
- Explore available visualization options before creating plots
- Understand what element types are supported in your environment
- Find the right element name to use with HoloViews
## Returns
A sorted list of all HoloViews element names available in the current environment.
**Examples:** `['Annotation', 'Area', 'Arrow', 'Bars', 'Curve', 'Scatter', ...]`
## Next Steps
After discovering elements with this tool, use:
- [`hv_get`](./hv_get) - Get detailed documentation for a specific element
"""
@pn.cache
async def hv_list_elements() -> list[str]:
"""Fetch the list of HoloViews elements via the hv_list tool."""
response = await call_tool(
tool_name="hv_list",
parameters={},
)
return response.data
async def create_content():
"""Create the styled content displaying HoloViews elements as chips."""
items = await hv_list_elements()
count = pmui.Typography(
f"Found {len(items)} elements",
variant="subtitle1",
sx={"color": "text.secondary", "mb": 2},
)
chips = pmui.FlexBox(
*[pmui.Chip(item, variant="outlined", color="primary", size="small") for item in items],
sizing_mode="stretch_width",
)
return pmui.Column(count, chips, sizing_mode="stretch_width")
def create_app():
"""Create the Panel Material UI app for demoing the hv_list tool."""
about_button = pmui.IconButton(
label="About",
icon="info",
description="Click to learn about the HoloViews List Elements Tool.",
sizing_mode="fixed",
color="light",
margin=(10, 0),
)
about = pmui.Dialog(ABOUT, close_on_click=True, width=0)
about_button.js_on_click(args={"about": about}, code="about.data.open = true")
github_button = pmui.IconButton(
label="Github",
icon="star",
description="Give HoloViz-MCP a star on GitHub",
sizing_mode="fixed",
color="light",
margin=(10, 0),
href="https://github.com/MarcSkovMadsen/holoviz-mcp",
target="_blank",
)
content = pn.panel(create_content, loading_indicator=True)
main = pmui.Container(about, content)
return pmui.Page(
title="HoloViz-MCP: hv_list Tool Demo",
header=[pmui.Row(pn.HSpacer(), about_button, github_button, sizing_mode="stretch_width")],
main=[main],
)
if pn.state.served:
create_app().servable()