add visualize_chunk to generated skills and built-in RAG skill
This commit is contained in:
parent
174ece94cc
commit
9d986421a0
4 changed files with 41 additions and 0 deletions
|
|
@ -1,6 +1,14 @@
|
|||
# Changelog
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- **Chunk visualization for generated skills**: `visualize_chunk(chunk_id)` function exposed in generated skill packages, enabling callers to render visual grounding from chunk IDs in skill state
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Generated skill packages**: Include SKILL.md and assets in wheel distributions. Add README to generated packages.
|
||||
|
||||
## [0.35.1] - 2026-03-24
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -63,6 +63,15 @@ haiku-skills chat --use-entrypoints --skill recipes
|
|||
|
||||
Since each generated skill is self-contained with its own database and instructions, you can generate multiple skills for different domains and run them together. The agent sees each skill's description and routes questions to the appropriate knowledge base automatically.
|
||||
|
||||
Generated skills also expose `visualize_chunk()` for rendering visual grounding. Use chunk IDs from citations or search results in state:
|
||||
|
||||
```python
|
||||
from my_skill import visualize_chunk
|
||||
|
||||
images = await visualize_chunk(chunk_id)
|
||||
# Returns list of PIL Images with highlighted bounding boxes
|
||||
```
|
||||
|
||||
See [CLI: Create Skill](../cli.md#create-skill) for all options.
|
||||
|
||||
## Database Path Resolution
|
||||
|
|
|
|||
|
|
@ -75,3 +75,14 @@ def create_skill() -> Skill:
|
|||
state_type=SkillState,
|
||||
state_namespace="{{ name }}",
|
||||
)
|
||||
|
||||
|
||||
async def visualize_chunk(chunk_id: str) -> list:
|
||||
from haiku.rag.client import HaikuRAG
|
||||
|
||||
config = _get_config()
|
||||
async with HaikuRAG(_DB_PATH, config=config, read_only=True) as rag:
|
||||
chunk = await rag.get_chunk_by_id(chunk_id)
|
||||
if chunk is None:
|
||||
return []
|
||||
return await rag.visualize_chunk(chunk)
|
||||
|
|
|
|||
|
|
@ -260,6 +260,19 @@ class TestRenderTemplates:
|
|||
assert "recipes" in content
|
||||
assert "haiku-rag" in content
|
||||
|
||||
def test_visualize_chunk_function_present(self, tmp_path):
|
||||
render_templates(
|
||||
output_dir=tmp_path,
|
||||
name="docs",
|
||||
description="A docs skill.",
|
||||
tool_names=["search"],
|
||||
)
|
||||
init = tmp_path / "docs-skill" / "docs_skill" / "__init__.py"
|
||||
content = init.read_text()
|
||||
assert "async def visualize_chunk(chunk_id: str)" in content
|
||||
assert "skill_visualize_chunk" not in content
|
||||
assert "HaikuRAG" in content
|
||||
|
||||
def test_generated_python_is_valid(self, tmp_path):
|
||||
render_templates(
|
||||
output_dir=tmp_path,
|
||||
|
|
|
|||
Loading…
Reference in a new issue