Skip to main content

humanlayer

Project description

Wordmark Logo of HumanLayer

HumanLayer: A python toolkit to enable AI agents to communicate with humans in tool-based and asynchronous workflows. By incorporating humans-in-the-loop, agentic tools can be given access to much more powerful and meaningful tool calls and tasks.

Bring your LLM (OpenAI, Llama, Claude, etc) and Framework (LangChain, CrewAI, etc) and start giving your AI agents safe access to the world.

Table of contents

Getting Started

To get started, check out Getting Started, watch the 2:30 Getting Started Video, or jump straight into one of the Examples:

pip install humanlayer

or for the bleeding edge

pip install git+https://github.com/humanlayer/humanlayer-ai-llm-agents

Set HUMANLAYER_API_TOKEN and wrap your AI function in require_approval()

from humanlayer import ApprovalMethod, HumanLayer
hl = HumanLayer.cloud() # or CLI

@hl.require_approval()
def send_email(to: str, subject: str, body: str):
    """Send an email to the customer"""
    ...


# made up method, use whatever framework you prefer
run_llm_task(
    prompt="Send an email welcoming the customer to the platform and encouraging them to invite a team member.",
    tools=[send_email],
    llm=OpenAI(model="gpt-4o")
)

Then you can start manging LLM actions in slack, email, or whatever channel you prefer:

A screenshot of slack showing a human replying to the bot

Check out the HumanLayer Docs and the Getting Started Guide for more information.

Why HumanLayer?

Functions and tools are a key part of Agentic Workflows. They enable LLMs to interact meaningfully with the outside world and automate broad scopes of impactful work. Correct and accurate function calling is essential for AI agents that do meaningful things like book appointments, interact with customers, manage billing information, write+execute code, and more.

Tool Calling Loop from Louis Dupont From https://louis-dupont.medium.com/transforming-software-interactions-with-tool-calling-and-llms-dc39185247e9

However, the most useful functions we can give to an LLM are also the most risky. We can all imagine the value of an AI Database Administrator that constantly tunes and refactors our SQL database, but most teams wouldn't give an LLM access to run arbitrary SQL statements against a production database (heck, we mostly don't even let humans do that). That is:

Even with state-of-the-art agentic reasoning and prompt routing, LLMs are not sufficiently reliable to be given access to high-stakes functions without human oversight

To better define what is meant by "high stakes", some examples:

  • Low Stakes: Read Access to public data (e.g. search wikipedia, access public APIs and DataSets)
  • Low Stakes: Communicate with agent author (e.g. an engineer might empower an agent to send them a private Slack message with updates on progress)
  • Medium Stakes: Read Access to Private Data (e.g. read emails, access calendars, query a CRM)
  • Medium Stakes: Communicate with strict rules (e.g. sending based on a specific sequence of hard-coded email templates)
  • High Stakes: Communicate on my Behalf or on behalf of my Company (e.g. send emails, post to slack, publish social/blog content)
  • High Stakes: Write Access to Private Data (e.g. update CRM records, modify feature toggles, update billing information)
Image showing the levels of function stakes stacked on top of one another

The high stakes functions are the ones that are the most valuable and promise the most impact in automating away human workflows. The sooner teams can get Agents reliably and safely calling these tools, the sooner they can reap massive benefits.

HumanLayer provides a set of tools to deterministically guarantee human oversight of high stakes function calls. Even if the LLM makes a mistake or hallucinates, HumanLayer is baked into the tool/function itself, guaranteeing a human in the loop.

Function Layer @require_approval decorator wrapping the Commnicate on my behalf function

HumanLayer provides a set of tools to *deterministically* guarantee human oversight of high stakes function calls

Key Features

  • Require Human Approval for Function Calls: the @hl.require_approval() decorator blocks specifc function calls until a human has been consulted - upon denial, feedback will be passed to the LLM
  • Human as Tool: generic hl.human_as_tool() allows for contacting a human for answers, advice, or feedback
  • OmniChannel Contact: Contact humans and collect responses across Slack, Email, Discord, and more
  • Granular Routing: Route approvals to specific teams or individuals
  • Bring your own LLM + Framework: Because HumanLayer is implemented at tools layer, it supports any LLM and all major orchestration frameworks that support tool calling.

Examples

You can test different real life examples of HumanLayer in the examples folder:

Roadmap

Feature Status
Require Approval ⚗️ Alpha
Human as Tool ⚗️ Alpha
CLI Approvals ⚗️ Alpha
CLI Human as Tool 🗓️ Planned
Slack Approvals ⚗️ Alpha
Langchain Support ⚗️ Alpha
Controlflow Support ⚗️ Alpha
CrewAI Support ⚗️ Alpha
Open Protocol for BYO server 🗓️ Planned
Composite Contact Channels 🚧 Work in progress
Discord Approvals 🗓️ Planned
Email Approvals 🗓️ Planned
LLamaIndex Support 🗓️ Planned
Haystack Support 🗓️ Planned

Contributing

HumanLayer is open-source and we welcome contributions in the form of issues, documentation, pull requests, and more. See CONTRIBUTING.md for more details.

License

The HumanLayer SDK in this repo is licensed under the Apache 2 License.

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

humanlayer-0.4.0.tar.gz (11.7 kB view hashes)

Uploaded Source

Built Distribution

humanlayer-0.4.0-py3-none-any.whl (9.7 kB view hashes)

Uploaded Python 3

Supported by

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