Skip to main content

Anthropic Agent Skills implementation for LangChain

Project description

LangChain Skills Adapter

This package provides an easy way to work with Agent Skills in your LangChain/LangGraph project by treating Skills as any other tool in LangChain, allowing you to easily integrate skills with existing workflows and agents. For developers, Skills work like any other LangChain tool.

alt text

Installation

Install from PyPI:

pip install langchain-skills-adapter

Create SkillTool

SkillTool accepts 2 arguments: directories (required) and description_template (optional).

Supported Directory Structures:

Scenario 1 - Direct skill directory:

skills/
└── pdf/
    └── SKILL.md          # Skill name: "pdf"

Usage: SkillTool(directories="skills/pdf")

Scenario 2 - Parent directory with multiple skills:

.copilot/skills/
├── pdf/
│   └── SKILL.md          # Skill name: "pdf"
├── pptx/
│   └── SKILL.md          # Skill name: "pptx"
└── excel/
    └── SKILL.md          # Skill name: "excel"

Usage: SkillTool(directories=".copilot/skills") # Discovers all three skills

Scenario 3 - Nested skill directories:

skills/
├── documents/
│   ├── pdf/
│   │   └── SKILL.md      # Skill name: "pdf"
│   └── word/
│       └── SKILL.md      # Skill name: "word"
└── data/
    └── csv/
        └── SKILL.md      # Skill name: "csv"

Usage: SkillTool(directories="skills") # Recursively discovers all nested skills

Scenario 4 - Multiple parent directories:

~/.agents/skills/
└── pdf/
    └── SKILL.md          # Skill name: "pdf"

./custom-skills/
└── excel/
    └── SKILL.md          # Skill name: "excel"

Usage: SkillTool(directories=["~/.agents/skills", "./custom-skills"])

from langchain_skills import SkillTool

# Load skills from a directory
skill_tool = SkillTool(directories=".agent/skills/")

Example Usage

from langchain_community.agent_toolkits import FileManagementToolkit
from langchain_community.tools import ShellTool

from langchain_skills import SkillTool

# Load skills from a directory
skill_tool = SkillTool(directories=".agent/skills/")

# Create tools
file_management_toolkit = FileManagementToolkit(root_dir='..').get_tools()
bash_tool = ShellTool()

# Combine all tools
tools = file_management_toolkit + [bash_tool, skill_tool]

agent = create_agent(model, tools)

It is highly recommended to provide FileManagementToolkit and ShellTool, which act as supporting tools in case your skill is not just a SKILL.md file. Even if the skill is a simple single SKILL.md file, it depends on what is actually written in that SKILL.md file. It depends on your use case.

Important:

Since this setup makes use of FileSystemTools and ShellTool, ensure proper security and safety measures. This is not the responsibility of this library.

Inspiration

This work is inspired by Spring AI's SkillTool implementation:
https://github.com/spring-ai-community/spring-ai-agent-utils/blob/main/spring-ai-agent-utils/src/main/java/org/springaicommunity/agent/tools/SkillsTool.java

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_skills_adapter-0.1.1.tar.gz (481.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_skills_adapter-0.1.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file langchain_skills_adapter-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_skills_adapter-0.1.1.tar.gz
  • Upload date:
  • Size: 481.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for langchain_skills_adapter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c6f198ecac53b1fb098001f545a7409727bd9b4895f891f2cd8fd18976f4d1a0
MD5 c751b5ef05a2a91a8c74505585a9c9f5
BLAKE2b-256 e3bafe8de20537f9542fb5faa84b1bb31902f9b479480fd4186716de4dcc0806

See more details on using hashes here.

File details

Details for the file langchain_skills_adapter-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_skills_adapter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 79c26291a790c9212d90d7e2fde3804aec6af4a13bc9016d16bb1acef7adc31d
MD5 cb7403c0fada0ed11e6b38bb2b3aacba
BLAKE2b-256 2462b213d8370906d9a80a4d066b3b1875efad792f9136990fb6dfee41441c7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page