Minor fixes
This commit is contained in:
parent
705ce80b4f
commit
75b9a172cb
6 changed files with 11 additions and 7 deletions
|
|
@ -261,7 +261,7 @@ The generated package is a pip-installable Python package that registers as a `h
|
||||||
|
|
||||||
| Flag | Description | Default |
|
| Flag | Description | Default |
|
||||||
|------|-------------|---------|
|
|------|-------------|---------|
|
||||||
| `--name` | Skill name (lowercase Python identifier, required) | — |
|
| `--name` | Skill name (lowercase alphanumeric and hyphens, required) | — |
|
||||||
| `--db` | Path to LanceDB database to embed (required) | — |
|
| `--db` | Path to LanceDB database to embed (required) | — |
|
||||||
| `--description` | Skill description | Standard RAG description |
|
| `--description` | Skill description | Standard RAG description |
|
||||||
| `--tools` | Comma-separated tool names, or `all` | `all` |
|
| `--tools` | Comma-separated tool names, or `all` | `all` |
|
||||||
|
|
|
||||||
|
|
@ -724,7 +724,7 @@ def create_skill_cmd( # pragma: no cover
|
||||||
name: str = typer.Option(
|
name: str = typer.Option(
|
||||||
...,
|
...,
|
||||||
"--name",
|
"--name",
|
||||||
help="Skill name (must be a lowercase Python identifier)",
|
help="Skill name (lowercase alphanumeric and hyphens)",
|
||||||
),
|
),
|
||||||
db: Path = typer.Option(
|
db: Path = typer.Option(
|
||||||
...,
|
...,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
|
from importlib.metadata import version
|
||||||
|
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
from jinja2 import Environment, PackageLoader
|
||||||
|
|
||||||
AVAILABLE_TOOLS: set[str] = {
|
AVAILABLE_TOOLS: set[str] = {
|
||||||
"list_documents",
|
"list_documents",
|
||||||
|
|
@ -28,7 +29,7 @@ DEFAULT_DESCRIPTION = (
|
||||||
def _get_env() -> Environment:
|
def _get_env() -> Environment:
|
||||||
return Environment(
|
return Environment(
|
||||||
loader=PackageLoader("haiku.rag.skill_generator", "templates"),
|
loader=PackageLoader("haiku.rag.skill_generator", "templates"),
|
||||||
autoescape=select_autoescape(),
|
autoescape=False,
|
||||||
keep_trailing_newline=True,
|
keep_trailing_newline=True,
|
||||||
lstrip_blocks=True,
|
lstrip_blocks=True,
|
||||||
trim_blocks=True,
|
trim_blocks=True,
|
||||||
|
|
@ -78,6 +79,7 @@ def render_templates(
|
||||||
preamble = DEFAULT_PREAMBLE
|
preamble = DEFAULT_PREAMBLE
|
||||||
|
|
||||||
pkg_name = name.replace("-", "_")
|
pkg_name = name.replace("-", "_")
|
||||||
|
rag_version = version("haiku.rag-slim")
|
||||||
env = _get_env()
|
env = _get_env()
|
||||||
context = {
|
context = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
|
@ -85,6 +87,7 @@ def render_templates(
|
||||||
"description": description,
|
"description": description,
|
||||||
"tool_names": tool_names,
|
"tool_names": tool_names,
|
||||||
"preamble": preamble,
|
"preamble": preamble,
|
||||||
|
"rag_version": rag_version,
|
||||||
}
|
}
|
||||||
|
|
||||||
result_dir = output_dir / f"{name}-skill"
|
result_dir = output_dir / f"{name}-skill"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ version = "0.1.0"
|
||||||
description = "{{ description }}"
|
description = "{{ description }}"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"haiku.rag-slim >= 0.35",
|
"haiku.rag-slim >= {{ rag_version }}",
|
||||||
"haiku-skills >= 0.10.0",
|
"haiku-skills >= 0.10.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from pydantic_ai import RunContext
|
||||||
|
|
||||||
from haiku.rag.agents.research.models import Citation
|
from haiku.rag.agents.research.models import Citation
|
||||||
from haiku.rag.config.models import AppConfig
|
from haiku.rag.config.models import AppConfig
|
||||||
|
from haiku.rag.store.models.chunk import SearchResult
|
||||||
from haiku.rag.tools.document import DocumentInfo
|
from haiku.rag.tools.document import DocumentInfo
|
||||||
from haiku.rag.tools.qa import QAHistoryEntry
|
from haiku.rag.tools.qa import QAHistoryEntry
|
||||||
from haiku.skills.state import SkillRunDeps
|
from haiku.skills.state import SkillRunDeps
|
||||||
|
|
@ -66,7 +67,7 @@ async def skill_search(
|
||||||
query: str,
|
query: str,
|
||||||
limit: int | None = None,
|
limit: int | None = None,
|
||||||
document_filter: str | None = None,
|
document_filter: str | None = None,
|
||||||
) -> tuple[str, list]:
|
) -> tuple[str, list[SearchResult]]:
|
||||||
from haiku.rag.client import HaikuRAG
|
from haiku.rag.client import HaikuRAG
|
||||||
|
|
||||||
async with HaikuRAG(db_path, config=config, read_only=True) as rag:
|
async with HaikuRAG(db_path, config=config, read_only=True) as rag:
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class TestRenderTemplates:
|
||||||
assert 'name = "recipes-skill"' in content
|
assert 'name = "recipes-skill"' in content
|
||||||
assert 'description = "A recipe skill."' in content
|
assert 'description = "A recipe skill."' in content
|
||||||
assert 'recipes = "recipes_skill:create_skill"' in content
|
assert 'recipes = "recipes_skill:create_skill"' in content
|
||||||
assert "haiku.rag-slim >= 0.35" in content
|
assert "haiku.rag-slim >= " in content
|
||||||
|
|
||||||
def test_skill_md_conditionals(self, tmp_path):
|
def test_skill_md_conditionals(self, tmp_path):
|
||||||
render_templates(
|
render_templates(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue