Skip to content

Commit d5e904a

Browse files
feat: add document chunking and search content modes (chunk/truncated/full)
Implement document chunking for large markdown files and extend the search() content parameter to support string modes ('chunk', 'truncated', 'full') alongside the existing boolean values for backward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e8ce2c2 commit d5e904a

6 files changed

Lines changed: 776 additions & 125 deletions

File tree

src/holoviz_mcp/apps/holoviz_search.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
- **`query`**: Your search text - the tool uses semantic similarity to find the most relevant documents
4141
- **`project`**: Filter results by specific project (e.g., "panel", "hvplot", "datashader") or search across all projects
4242
- **`max_results`**: Control the number of results returned (1-50 documents)
43-
- **`content`**: Choose whether to include full document content or just metadata for faster responses
43+
- **`content`**: Controls what content is returned per result:
44+
- `"truncated"` (default): Full document content, smart-truncated around query keywords
45+
- `"chunk"`: Only the best-matching chunk from the document (useful for quick snippets)
46+
- `"full"`: Complete document content with no truncation (can be very large)
47+
- `"none"`: No content, metadata only (fastest)
4448
- **`max_content_chars`**: Maximum characters of content per result (100-50,000). Smaller values provide faster responses. Content is truncated at word boundaries with query-relevant excerpts.
4549
4650
### Query Optimization Tips
@@ -103,8 +107,11 @@ class SearchConfiguration(param.Parameterized):
103107

104108
max_results = param.Integer(default=2, bounds=(1, 50), doc="Maximum number of search results to return")
105109

106-
content = param.Boolean(
107-
default=True, label="Include Full Content", doc="Include full document content in results. Disable for faster and simpler responses with metadata only."
110+
content = param.Selector(
111+
default="truncated",
112+
objects=["truncated", "chunk", "full", "none"],
113+
doc='Controls what content is returned. "truncated": full doc smart-truncated around query keywords (default). '
114+
'"chunk": only best-matching chunk. "full": complete document, no truncation. "none": metadata only (fastest).',
108115
)
109116

110117
max_content_chars = param.Integer(
@@ -131,9 +138,8 @@ def __init__(self, **params):
131138
async def _update_results(self):
132139
indexer = _get_indexer()
133140
project = self.project if self.project != ALL else None
134-
self.results = await indexer.search(
135-
self.query, project=project, content=self.content, max_results=self.max_results, max_content_chars=self.max_content_chars
136-
)
141+
content = self.content if self.content != "none" else False
142+
self.results = await indexer.search(self.query, project=project, content=content, max_results=self.max_results, max_content_chars=self.max_content_chars)
137143

138144

139145
async def _update_projects(self):

0 commit comments

Comments
 (0)