Skip to main content

SkillBroker LangChain Integration

Add expert knowledge to your LangChain agents with SkillBroker - the marketplace where AI agents pay for human expertise.

Installation

pip install skillbroker-langchain

Quick Start

Using a Specific Skill

from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from skillbroker_langchain import SkillBrokerTool

# Create a tool for a specific skill
tax_advisor = SkillBrokerTool(
    skill_id="freelancer-tax-advisor",
    name="tax_advisor",
    description="Get expert advice on freelancer and self-employment tax questions"
)

# Set up your agent
llm = ChatOpenAI(model="gpt-4")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant. Use the tax_advisor tool for tax questions."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])

agent = create_openai_tools_agent(llm, [tax_advisor], prompt)
executor = AgentExecutor(agent=agent, tools=[tax_advisor])

# Ask a question
result = executor.invoke({"input": "Can I deduct my home office as a freelancer?"})
print(result["output"])

Searching for Skills

from skillbroker_langchain import SkillBrokerSearchTool

# Create a search tool
search = SkillBrokerSearchTool()

# Find relevant skills
results = search.invoke({"query": "financial planning"})
print(results)

Dynamic Expert Tool

Let the agent automatically find and use the right skill:

from skillbroker_langchain import SkillBrokerDynamicTool

# This tool can handle any domain question
expert = SkillBrokerDynamicTool(
    name="expert_knowledge",
    description="Get expert knowledge on any specialized topic"
)

# The tool will search for and invoke the best matching skill
result = expert.invoke({"query": "What's the best way to structure a holding company?"})

Using the Client Directly

from skillbroker_langchain import SkillBrokerClient

client = SkillBrokerClient()

# Get registry info
info = client.get_registry_info()
print(f"Total skills available: {info['stats']['totalSkills']}")

# Search for skills
results = client.search("machine learning")
for skill in results.skills:
    print(f"- {skill.name}: {skill.description}")

# Get top-rated skills
top_skills = client.get_top_skills(limit=5)

# Invoke a skill directly
response = client.invoke("skill-id", "Your question here")
print(response.response)

Configuration

Environment Variables

# Optional: Override the API URL (defaults to https://api.skillbroker.io)
export SKILLBROKER_API_URL="https://api.skillbroker.io"

# Optional: API key for authenticated requests
export SKILLBROKER_API_KEY="your-api-key"

Programmatic Configuration

from skillbroker_langchain import SkillBrokerClient, SkillBrokerTool

# Configure client
client = SkillBrokerClient(
    api_url="https://api.skillbroker.io",
    api_key="your-api-key",
    timeout=30,
)

# Configure tools
tool = SkillBrokerTool(
    skill_id="my-skill",
    api_url="https://api.skillbroker.io",
    api_key="your-api-key",
)

Available Tools

Tool Description
SkillBrokerTool Invoke a specific skill by ID
SkillBrokerSearchTool Search the marketplace for skills
SkillBrokerDynamicTool Automatically find and invoke the best skill

Examples

Multi-Tool Agent

from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
from skillbroker_langchain import SkillBrokerTool, SkillBrokerSearchTool

# Create multiple skill tools
tax_tool = SkillBrokerTool(
    skill_id="freelancer-tax-advisor",
    name="tax_advisor",
    description="Tax advice for freelancers"
)

legal_tool = SkillBrokerTool(
    skill_id="contract-reviewer",
    name="contract_advisor",
    description="Contract and legal document review"
)

search_tool = SkillBrokerSearchTool()

# Use all tools in your agent
tools = [tax_tool, legal_tool, search_tool]
agent = create_openai_tools_agent(llm, tools, prompt)

With CrewAI

from crewai import Agent, Task, Crew
from skillbroker_langchain import SkillBrokerTool

# Create SkillBroker tools
tax_tool = SkillBrokerTool(
    skill_id="freelancer-tax-advisor",
    name="tax_advisor",
    description="Expert tax advice"
)

# Create a CrewAI agent with the tool
tax_agent = Agent(
    role="Tax Consultant",
    goal="Provide accurate tax advice",
    backstory="You are an expert tax consultant.",
    tools=[tax_tool],
)

task = Task(
    description="Help the user understand their tax obligations",
    agent=tax_agent,
)

crew = Crew(agents=[tax_agent], tasks=[task])
result = crew.kickoff()

API Reference

SkillBrokerClient

client = SkillBrokerClient(api_url=None, api_key=None, timeout=30)

# Methods
client.get_registry_info() -> dict
client.search(query=None, category=None, limit=20) -> SearchResult
client.get_skill(skill_id) -> Skill
client.invoke(skill_id, query, context=None) -> SkillResponse
client.get_categories() -> list
client.get_top_skills(limit=10, category=None) -> list[Skill]
client.get_recommendations(task_description, limit=5) -> list[Skill]

Models

from skillbroker_langchain import Skill, SkillResponse, SkillQuery

# Skill attributes
skill.id
skill.name
skill.description
skill.category
skill.pricing
skill.stats
skill.quality

# Response attributes
response.success
response.response
response.skill_id
response.tokens_used
response.cost

Support

License

MIT License - see LICENSE file for details.

Metadata

Release files for skillbroker-langchain 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skillbroker-langchain 0.1.0
File Size Uploaded
skillbroker_langchain-0.1.0.tar.gz 16.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for skillbroker-langchain 0.1.0
File Interpreter ABI Platform
skillbroker_langchain-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.4 kB

Release files / skillbroker_langchain-0.1.0.tar.gz

Download URL skillbroker_langchain-0.1.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3f067adcb6348bd596c182bbfc5ef4ec79c024872af173069fc3c1e9ee58fa97
BLAKE2b-256 checksum
How to use checksums
7d95bab214722110b71f864859a746c6f5c422e5356c7e851bd7d003f8d9a357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / skillbroker_langchain-0.1.0-py3-none-any.whl

Download URL skillbroker_langchain-0.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d6d1c3fd29f014979f8dea33dc0db58cc411dc949e1a86c48501cd099434457
BLAKE2b-256 checksum
How to use checksums
70b7ef9de6a06c14d5b03a7cecfc8ce38072c09ad851f59a6587bde2061f38e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page