界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
开发与工程 · SKILL.md

custom-skills

custom-skills

【开发与工程】Guides PandasAI custom function skills, @pai.skill decorators, SkillType validation, global registry management, and skill-related troubleshooting.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: custom-skills description: "Guides PandasAI custom function skills, @pai.skill decorators, SkillType validation, global registry management, and skill-related troubleshooting." disable-model-invocation: true metadata: disco-role: operating license: NOASSERTION

Custom Skills

Use this sub-skill when a user wants PandasAI to make custom Python functions available to generated analysis code through @pai.skill() or the pandasai.ee.skills registry.

PandasAI custom skills are runtime functions for PandasAI-generated code. They are not DisCo Agent Skills and are not SKILL.md directories.

Fast route

  1. Define a normal Python function with type hints and a useful docstring.
  2. Decorate it with @pai.skill() or @pai.skill("custom_name").
  3. Configure the LLM and run PandasAI chat as usual.
  4. If testing registry behavior, clear SkillsManager between tests to avoid duplicate-name leakage.
  5. If the task is about using those functions during chat, route back to ../conversational-analysis/SKILL.md after registration is correct.
import pandasai as pai

@pai.skill()
def format_currency(amount: float) -> str:
    """Format a numeric amount as US dollars."""
    return f"${amount:,.2f}"

Read next

Boundaries

Enterprise note

PandasAI documentation marks custom skills as an Enterprise feature for production use. For local experimentation and tests, the decorator and registry exist in the package. For production deployments, warn the user to confirm their PandasAI license/plan.

Safe validation

python sub-skills/custom-skills/scripts/skill_registry_smoke.py

The helper registers a small skill, verifies duplicate-name protection, verifies no-docstring failure behavior, and prints JSON. It does not need a real LLM or provider key.

Common gotchas

  • A function must have a docstring unless SkillType(..., description=...) is used directly.
  • Duplicate skill names in the global registry raise ValueError.
  • Decorated functions are replaced by SkillType objects, but remain callable.
  • Registry state is global; clear it in tests before registering predictable names.
  • Lambdas need an explicit name and description when wrapped directly.
我的收藏