A modern, interactive viewer for exploring CopilotKit agent demos with a clean, responsive UI and dark/light theme support.
The Demo Viewer provides a centralized interface for browsing, viewing, and exploring the source code of various CopilotKit agent demos. It features:
- Clean, modern UI with dark/light theme support
- Interactive demo previews
- Source code exploration with syntax highlighting
- Organized demo listing with tags and descriptions
- LLM provider selection
To run the Demo Viewer locally for development, follow these steps:
You'll need to set up environment variables for both the root directory and the agent directory:
# In the root directory
echo "OPENAI_API_KEY=your_api_key_here" > .env
# In the agent directory
cd agent
echo "OPENAI_API_KEY=your_api_key_here" > .env
cd ..Make sure to replace your_api_key_here with your actual OpenAI API key.
By default, the viewer shows demos built with CrewAI. To view demos built with LangGraph, you need to set the NEXT_PUBLIC_AGENT_TYPE environment variable in the root directory's .env file.
Add the following line to the .env file in the project root:
# Set to 'langgraph' to view LangGraph demos, or 'crewai' for CrewAI demos (default)
NEXT_PUBLIC_AGENT_TYPE=langgraphMake sure to restart the Demo Viewer (pnpm run dev) after changing this variable.
The setup process differs depending on whether you are running CrewAI or LangGraph demos.
- Navigate to the agents directory:
cd agent - Install dependencies using Poetry:
poetry install
- Start the CrewAI agent server:
poetry run crew_server
If you have set NEXT_PUBLIC_AGENT_TYPE=langgraph in the root .env file, follow these steps:
- Navigate to the agents directory:
cd agent - Create and activate a Python 3.12 virtual environment:
(Ensure you have Python 3.12 installed)
python3.12 -m venv .venv source .venv/bin/activate - Install base dependencies using Poetry:
poetry install
- Install LangGraph API and CLI packages:
pip install -U langgraph-api pip install "langgraph-cli[inmem]" - Run the LangGraph development server:
poetry run langgraph dev --host localhost --port 8000 --no-browser
This will start the backend server that powers the LangGraph agent demos on port 8000.
To connect the Demo Viewer frontend to your local LangGraph development server, you may need to create a secure tunnel using the CopilotKit CLI. In a separate terminal, run:
npx copilotkit dev --port 8000 --project <your_project_id>Replace <your_project_id> with your actual CopilotKit project ID. This command forwards requests from a public URL to your local server on port 8000.
In a new terminal, navigate to the project root and start the Demo Viewer:
pnpm install
pnpm run devThe Demo Viewer should now be running at http://localhost:3000.
To add a new demo to the viewer, follow these steps:
Create a new folder for your demo inside the agents/demo directory:
agents/demo/your-demo-name/
Inside this folder, add the following files:
__init__.py- An empty file required for Python package importsagent.py- The main Python file for your agent implementation- Any additional Python modules your agent needs to import
page.tsx- The main React component for your demo- Any additional styles or components needed
The agent.py file is particularly important as it's the entry point for your agent's functionality. Make sure it follows the agent implementation pattern used in other demos.
You need to register your agent in the server.py file so it can be discovered and used by the server:
- Open
agent/server.py - Look at how existing demos are registered in the file
- Follow the same pattern to register your new agent
- Make sure to use the correct import path and route that matches your demo's ID
This step is crucial for making your agent accessible through the API. Check existing implementations in the server.py file for the exact syntax and pattern to follow.
Open src/demos/config.ts and add your demo to the configuration array:
{
id: "your-demo-name", // Must match the folder name in agents/demo
name: "Your Demo Name",
description: "A brief description of what your demo does",
path: "agents/demo/your-demo-name",
tags: ["tag1", "tag2"], // Relevant tags for categorization
defaultLLMProvider: "openai" // Default LLM provider for this demo
}Important notes:
- The
idmust correspond to the folder name insideagents/demo - Ensure the
pathcorrectly points to your demo folder - Add relevant tags to help users find your demo
- Set an appropriate default LLM provider
Run the Demo Viewer as described in the Development Setup section and verify that your demo appears in the list and functions correctly.
src/app- Next.js app router filessrc/components- Reusable UI componentssrc/demos- Demo configuration and utilitiessrc/hooks- Custom React hookssrc/types- TypeScript type definitionspublic- Static assets
- Next.js
- React
- TypeScript
- Tailwind CSS
- CopilotKit