parent
8a859fbe3c
commit
8eee4fabb9
2 changed files with 48 additions and 12 deletions
|
|
@ -36,6 +36,27 @@ class RAGState(BaseModel):
|
|||
documents: list[DocumentInfo] = Field(default_factory=list)
|
||||
reports: list[ResearchEntry] = Field(default_factory=list)
|
||||
|
||||
STATE_NAMESPACE = "haiku.rag.skills.rag"
|
||||
STATE_TYPE = RAGState
|
||||
|
||||
_skill_path = Path(__file__).parent / "rag"
|
||||
_skill_metadata = None
|
||||
_instructions = None
|
||||
|
||||
def _parse_skill():
|
||||
global _skill_metadata
|
||||
global _instructions
|
||||
_skill_metadata, _instructions = parse_skill_md(_skill_path / "SKILL.md")
|
||||
|
||||
def skill_metadata():
|
||||
if _skill_metadata is None:
|
||||
_parse_skill()
|
||||
return _skill_metadata
|
||||
|
||||
def instructions():
|
||||
if _instructions is None:
|
||||
_parse_skill()
|
||||
return _instructions
|
||||
|
||||
def create_skill(
|
||||
db_path: Path | None = None,
|
||||
|
|
@ -62,9 +83,6 @@ def create_skill(
|
|||
else:
|
||||
db_path = config.storage.data_dir / "haiku.rag.lancedb"
|
||||
|
||||
path = Path(__file__).parent / "rag"
|
||||
metadata, instructions = parse_skill_md(path / "SKILL.md")
|
||||
|
||||
async def _find_relevant_prior_qa(
|
||||
state: RAGState, query: str
|
||||
) -> list[QAHistoryEntry]:
|
||||
|
|
@ -323,10 +341,10 @@ def create_skill(
|
|||
return "\n".join(parts)
|
||||
|
||||
return Skill(
|
||||
metadata=metadata,
|
||||
metadata=skill_metadata(),
|
||||
source=SkillSource.ENTRYPOINT,
|
||||
path=path,
|
||||
instructions=instructions,
|
||||
path=_skill_path,
|
||||
instructions=instructions(),
|
||||
tools=[
|
||||
search,
|
||||
list_documents,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,27 @@ class AnalysisEntry(BaseModel):
|
|||
class RLMState(BaseModel):
|
||||
analyses: list[AnalysisEntry] = []
|
||||
|
||||
STATE_NAMESPACE = "haiku.rag.skills.rag-rlm"
|
||||
STATE_TYPE = RLMState
|
||||
|
||||
_skill_path = Path(__file__).parent / "rag-rlm"
|
||||
_skill_metadata = None
|
||||
_instructions = None
|
||||
|
||||
def _parse_skill():
|
||||
global _skill_metadata
|
||||
global _instructions
|
||||
_skill_metadata, _instructions = parse_skill_md(_skill_path / "SKILL.md")
|
||||
|
||||
def skill_metadata():
|
||||
if _skill_metadata is None:
|
||||
_parse_skill()
|
||||
return _skill_metadata
|
||||
|
||||
def instructions():
|
||||
if _instructions is None:
|
||||
_parse_skill()
|
||||
return _instructions
|
||||
|
||||
def create_skill(
|
||||
db_path: Path | None = None,
|
||||
|
|
@ -45,9 +66,6 @@ def create_skill(
|
|||
else:
|
||||
db_path = config.storage.data_dir / "haiku.rag.lancedb"
|
||||
|
||||
path = Path(__file__).parent / "rag-rlm"
|
||||
metadata, instructions = parse_skill_md(path / "SKILL.md")
|
||||
|
||||
async def analyze(
|
||||
ctx: RunContext[SkillRunDeps],
|
||||
question: str,
|
||||
|
|
@ -85,10 +103,10 @@ def create_skill(
|
|||
return output
|
||||
|
||||
return Skill(
|
||||
metadata=metadata,
|
||||
metadata=skill_metadata(),
|
||||
source=SkillSource.ENTRYPOINT,
|
||||
path=path,
|
||||
instructions=instructions,
|
||||
path=_skill_path,
|
||||
instructions=instructions(),
|
||||
tools=[analyze],
|
||||
state_type=RLMState,
|
||||
state_namespace="rlm",
|
||||
|
|
|
|||
Loading…
Reference in a new issue