This is a full-stack AI assistant application template using the assistant-ui library. It consists of:
- Frontend: Next.js 15 application with React 19, TypeScript, and Tailwind CSS
- Backend: Python backend (separate service) that handles AI chat processing
- Architecture: Frontend serves as a proxy to the Python backend via
/api/chatroute
Frontend:
cd frontend
npm installBackend:
cd backend
uv syncmake frontend # Start frontend only
make backend # Start backend only
make dev # Start both serversSet your OpenAI API key for the backend:
export OPENAI_API_KEY=sk-your-key-hereapp/page.tsx- Main entry point, renders Assistant componentapp/assistant.tsx- Main assistant interface using assistant-uiapp/api/chat/route.ts- API proxy that forwards requests to Python backendcomponents/assistant-ui/- Custom assistant-ui componentscomponents/ui/- Reusable UI components using Radix UI primitiveslib/- Utility functions and constantspublic/- Static assetsstyles/- Global stylestsconfig.json- TypeScript configurationnext.config.js- Next.js configurationpackage.json- Project dependencies and scripts
cd frontend
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintcd backend
pytest tests/ # Run backend testsTo create a new tool, add a new function to backend/tools.py using the @tool decorator. For example:
@tool
def new_tool(arg1: str, arg2: int) -> str:
"""
Description of the tool.
"""
return f"Tool called with arg1: {arg1} and arg2: {arg2}"Then add the tool to the tools list in backend/agents.py:
from backend.tools import new_tool
agent = ToolCallingAgent(
model="gpt-4o-mini",
tools=[new_tool],
verbose=True,
)When the tool is called, the front end will display the tool name and arguments in the UI. To set what the label for the toolcall is, add it to
frontend/lib/tool-display-names.ts
You can customize the ports used by the development servers:
make dev FRONTEND_PORT=3001 BACKEND_PORT=8001 # Both with custom ports
make frontend FRONTEND_PORT=4000 # Frontend on port 4000
make backend BACKEND_PORT=9000 # Backend on port 9000
make help # See all available options