Skip to main content

What are Adapters?

Adapters are modular components that connect LangChat to external services. They provide:
  • Unified Interface - Consistent API across services
  • Error Handling - Robust retry logic
  • Easy Setup - Simple initialization
  • Flexible - Easy to extend or replace

Available Providers

Quick Setup

Initialize providers directly:
from langchat import LangChat
from langchat.llm import OpenAI
from langchat.vector_db import Pinecone
from langchat.database import Supabase

# Setup providers
llm = OpenAI(api_key="sk-...", model="gpt-4o-mini")
vector_db = Pinecone(api_key="...", index_name="...")
db = Supabase(url="https://...", key="...")

# Create chatbot
ai = LangChat(llm=llm, vector_db=vector_db, db=db)
All providers are initialized automatically when you create LangChat. No manual setup needed!

LLM Providers

OpenAI

from langchat.llm import OpenAI

llm = OpenAI(api_key="sk-...", model="gpt-4o-mini", temperature=0.7)

Other LLMs

from langchat.llm import Anthropic, Gemini, Ollama, Cohere, Mistral

# Anthropic
llm = Anthropic(api_key="...", model="claude-3-5-sonnet-20241022")

# Gemini
llm = Gemini(api_key="...", model="gemini-1.5-flash")

# Ollama (local)
llm = Ollama(model="llama2", base_url="http://localhost:11434")

Vector Database

Pinecone

from langchat.vector_db import Pinecone

vector_db = Pinecone(
    api_key="pcsk-...",
    index_name="your-index",
    embedding_model="text-embedding-3-large"
)

Database

Supabase

from langchat.database import Supabase

db = Supabase(
    url="https://xxxxx.supabase.co",
    key="eyJhbGc..."
)

Reranker

Flashrank

from langchat.reranker import Flashrank

reranker = Flashrank(
    model_name="ms-marco-MiniLM-L-12-v2",
    top_n=3
)

Accessing Providers

Access providers from the engine:
ai = LangChat(llm=llm, vector_db=vector_db, db=db)

# Access providers
engine = ai.engine
print(engine.llm)  # LLM provider
print(engine.vector_adapter)  # Vector database
print(engine.reranker_adapter)  # Reranker
print(engine.history_store)  # Database

Next Steps


Built with ❤️ by NeuroBrain