Response time breakdown
A typical LangChatchat() call involves:
The two LLM calls dominate. Everything else is fast.
Use a faster model
The single highest-impact change.gpt-4o-mini is ~5× faster and ~20× cheaper than gpt-4o:
Reduce context size
Smaller prompts = faster LLM calls + lower cost. Reduce history window:Use smaller embedding model
Switch totext-embedding-3-small for faster, cheaper embeddings:
Concurrent users
LangChat’schat() is async and non-blocking. Run multiple chats concurrently:
Session caching
Sessions are cached in memory. The first call for a user loads history from Supabase; subsequent calls use the in-memory cache. No extra configuration needed. After a server restart, the cache is empty — first calls incur a Supabase query. For large-scale deployments with many unique users, the history loading is fast (Supabase queries are indexed byuser_id and platform).
