chainlit-crew-adapter
chainlit-crew-adapter is a small library for running CrewAI crews inside Chainlit with a cleaner developer experience.
It focuses on two things:
- rendering CrewAI execution as Chainlit steps
- letting CrewAI agents ask the user follow-up questions with a reusable Chainlit-backed tool
Demo
Features
ChainlitCrewAdapterwith asynckickoff(...)- step rendering for crew, task, agent, and tool events
- optional
show_agent_steps=Falsefor cleaner traces ChainlitAskUserToolfor human-in-the-loop follow-up questions- examples for both step rendering and ask-user workflows
Usage
Installation from PyPI
pip install chainlit-crew-adapter
Setup
Before running the examples, set your OpenAI API credentials:
export OPENAI_API_KEY=your_openai_api_key
export OPENAI_MODEL=gpt-4o-mini # optional, defaults to gpt-4o-mini
Example 1: Step Rendering
Render CrewAI crew execution as Chainlit steps to see the full task and tool execution trace.
import chainlit as cl
from chainlit_crew_adapter import ChainlitCrewAdapter
from your_crew import build_my_crew
@cl.on_message
async def main(message: cl.Message) -> None:
crew = build_my_crew()
adapter = ChainlitCrewAdapter(cl=cl, crew=crew)
result = await adapter.kickoff(inputs={"user_request": message.content})
await cl.Message(content=str(result)).send()
For a complete example, see examples/steps_demo.py.
Example 2: Human Follow-up Questions
Enable the crew to ask users follow-up questions using the ChainlitAskUserTool.
import chainlit as cl
from chainlit_crew_adapter import ChainlitAskUserTool, ChainlitCrewAdapter
from your_crew import build_ask_user_crew
@cl.on_message
async def main(message: cl.Message) -> None:
ask_user_tool = ChainlitAskUserTool(
timeout_seconds=180,
author="Crew Assistant"
)
crew = build_ask_user_crew(ask_user_tool=ask_user_tool)
adapter = ChainlitCrewAdapter(
cl=cl,
crew=crew,
show_agent_steps=False # Cleaner trace without agent-level steps
)
result = await adapter.kickoff(inputs={"user_request": message.content})
await cl.Message(content=str(result)).send()
For a complete example, see examples/ask_user_demo.py.
Running the Examples
# Step rendering demo
chainlit run examples/steps_demo.py
# Human follow-up questions demo
chainlit run examples/ask_user_demo.py
Installation
Local development
pip install -e .
Or, if you prefer the repo requirements file:
pip install -r requirements.txt
Environment variables
At minimum, set:
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4o-mini
OPENAI_MODEL is optional. The examples default to gpt-4o-mini.
API
ChainlitCrewAdapter
ChainlitCrewAdapter(
cl: SupportsChainlit,
crew: Crew,
inputs: Mapping[str, object] | None = None,
*,
show_agent_steps: bool = True,
)
await adapter.kickoff(inputs=None)
Runs crew.kickoff(...) through Chainlit and mirrors CrewAI progress into the Chainlit step tree.
ChainlitAskUserTool
ChainlitAskUserTool(
*,
ask_user=None,
chainlit_context=None,
timeout_seconds: int = 120,
author: str = "Crew Assistant",
fail_on_timeout: bool = False,
)
Use this tool in CrewAI agents when they need to ask the user follow-up questions during execution.
Example Apps
This repo includes two example apps.
1. Step rendering demo
File:
examples/steps_demo.py
Run it with:
chainlit run examples/steps_demo.py
Try prompts like:
Analyze post 5
Summarize post 12
What it demonstrates:
- crew step rendering
- task, agent, and tool steps
- a real tool-driven CrewAI workflow with JSONPlaceholder
2. Ask-user demo
File:
examples/ask_user_demo.py
Run it with:
chainlit run examples/ask_user_demo.py
Try prompts like:
Help me plan a product launch
I need a landing page brief
What it demonstrates:
ChainlitAskUserTool- chat-based follow-up questions during crew execution
- a compact step trace using
show_agent_steps=False - a dedicated clarification step summarizing the questions asked in chat
Legacy alias
For backward compatibility, this file points to the ask-user demo:
examples/manual_crew_integration.py
Example Structure
chainlit_crew_adapter/
├── chainlit_crew_adapter/
│ ├── __init__.py
│ ├── adapter.py
│ ├── events.py
│ ├── human_input.py
│ └── step_renderer.py
├── examples/
│ ├── ask_user_demo.py
│ ├── manual_crew_integration.py
│ ├── steps_demo.py
│ └── crews/
│ ├── ask_user_demo/
│ └── steps_demo/
├── pyproject.toml
└── README.md
Notes
- CrewAI streaming crews are not supported yet in the adapter step renderer.
- The ask-user demo intentionally keeps the back-and-forth in chat and the execution trace in steps.
- The step renderer treats the ask-user tool as a special clarification flow to avoid noisy duplicate traces.
Development Checks
A quick local verification pass:
python -m py_compile chainlit_crew_adapter/*.py examples/*.py examples/crews/*/*.py
Next Step Toward Deployment
The repo now has a basic pyproject.toml, package data marker, examples, and a cleaner separation between library code and demos. The next natural step is publishing metadata cleanup and then building the distribution with:
python -m build
Metadata
Release files for chainlit-crew-adapter 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| chainlit_crew_adapter-0.0.2.tar.gz | 12.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chainlit_crew_adapter-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / chainlit_crew_adapter-0.0.2.tar.gz
| Download URL | chainlit_crew_adapter-0.0.2.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c2254a9ee062e0c59a0cadb7503b13e2d1b453b70a3b5798870efe8f52cc46e
|
|
BLAKE2b-256 checksum How to use checksums |
b2193bc7cc9af5c00b61bc176cd027ce36c82bab7005314299f565f046baf013
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / chainlit_crew_adapter-0.0.2-py3-none-any.whl
| Download URL | chainlit_crew_adapter-0.0.2-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4a3382ad610064dc238263ead84b24c3c2fe8ee5947cc09dc294b2352fd9acb
|
|
BLAKE2b-256 checksum How to use checksums |
5fd9f368a074c9eb3d1ba3c6aaa7001a69b013f141db5245871c24e9dfaa6cc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for chainlit-crew-adapter 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.