Skip to content

picahq/buildkit-langchain-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LangChain Starter

A simple LangChain starter with a FastAPI backend and modern chat UI interface.

Quickstart

# 1) Create & activate venv
python -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate

# 2) Install dependencies
pip install -r requirements.txt

# 3) Configure OpenAI
cp .env.example .env
# Edit .env and set OPENAI_API_KEY

# 4) Run the backend server
python -m src.backend

# 5) Open your browser
# Visit http://localhost:8000 to use the chat interface

Project Structure

langchain-starter/
├── src/
│   ├── __init__.py
│   ├── agent.py          # LangChain agent
│   └── backend.py        # FastAPI server with chat endpoints
├── frontend/
│   ├── index.html        # Chat interface
│   ├── styles.css        # Modern UI styling
│   └── script.js         # Frontend chat logic

├── requirements.txt     # Python dependencies
└── README.md

API Endpoints

  • GET / - Serves the chat interface
  • POST /api/chat - Chat with the LangChain agent
  • GET /api/health - Health check endpoint

Chat API Usage

# Send a message to the agent
curl -X POST "http://localhost:8000/api/chat" \
     -H "Content-Type: application/json" \
     -d '{"message": "Who are you?"}'

What's inside?

Backend (src/)

  • agent.py — LangChain agent
  • backend.py — FastAPI server with:
    • Chat endpoint for processing messages
    • CORS middleware for frontend communication
    • Static file serving for the chat interface

Frontend (frontend/)

  • Modern chat interface with:
    • Real-time message exchange
    • Typing indicators
    • Responsive design
    • Keyboard shortcuts

Extending the Agent

To add new tools to your agent, edit src/agent.py:

Development

Running in Development Mode

# Backend with auto-reload
python -m src.backend

# Or using uvicorn directly
uvicorn src.backend:app --reload --host 0.0.0.0 --port 8000

Learn More

Notes

  • Uses langchain-openai provider package (recommended modern setup)
  • FastAPI provides automatic API documentation at /docs
  • Frontend uses vanilla JavaScript (no framework dependencies)
  • CORS enabled for development (configure for production)

About

A starter LangChain project with a chat interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published