Skip to main content

Install LangChat

pip install langchat
Requires Python 3.8 or higher.

Your First Chatbot

Copy this code and run it:
import asyncio
from langchat import LangChat
from langchat.llm import OpenAI
from langchat.vector_db import Pinecone
from langchat.database import Supabase

async def main():
    # Setup providers
    llm = OpenAI(api_key="sk-...", model="gpt-4o-mini", temperature=0.7)
    vector_db = Pinecone(api_key="your-key", index_name="your-index")
    db = Supabase(url="https://xxxxx.supabase.co", key="your-key")
    
    # Create chatbot
    ai = LangChat(llm=llm, vector_db=vector_db, db=db)
    
    # Chat!
    result = await ai.chat(
        query="Hello! What can you help me with?",
        user_id="guest",
        domain="default"
    )
    print(result["response"])

asyncio.run(main())

What You Need

Before running, get these:
  1. OpenAI API Key: Get from platform.openai.com
  2. Pinecone Account: Sign up at pinecone.io and create an index
  3. Supabase Project: Create at supabase.com
Make sure your Pinecone index exists before running. Supabase tables are created automatically.

What Happens?

When you run the code:
  1. ✅ LangChat connects to your AI model
  2. ✅ Sets up search capabilities
  3. ✅ Creates database tables (if needed)
  4. ✅ Starts your chatbot
Everything happens automatically—no manual setup required!

Next Steps

🎉 Congratulations! You just built your first AI chatbot!

Built with ❤️ by NeuroBrain