Files
FusionAGI/fusionagi/skills/induction.py
defiQUG c052b07662
Some checks failed
Tests / test (3.10) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.12) (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / docker (push) Has been cancelled
Initial commit: add .gitignore and README
2026-02-09 21:51:42 -08:00

20 lines
1.2 KiB
Python

from typing import Any
from fusionagi.schemas.skill import Skill, SkillKind
from fusionagi._logger import logger
class SkillInduction:
def __init__(self, min_occurrences: int = 2) -> None:
self._min_occurrences = min_occurrences
def propose_from_traces(self, traces: list[list[dict[str, Any]]], task_ids: list[str] | None = None) -> list[Skill]:
candidates: list[Skill] = []
task_ids = task_ids or [f"task_{i}" for i in range(len(traces))]
for i, trace in enumerate(traces):
if not trace:
continue
step_ids = [t.get("step_id", t.get("tool", "")) for t in trace[:10]]
steps = [{"id": s, "description": str(s)} for s in step_ids]
skill_id = f"induced_{task_ids[i] if i < len(task_ids) else i}_{hash(tuple(step_ids)) % 10**6}"
candidates.append(Skill(skill_id=skill_id, name=f"Induced routine {i}", description=f"From trace: {step_ids[:3]}", kind=SkillKind.WORKFLOW, steps=steps, tool_names=list({t.get("tool", "") for t in trace if t.get("tool")}), version=1))
logger.info("SkillInduction proposed", extra={"count": len(candidates)})
return candidates