Documentation Index
Fetch the complete documentation index at: https://langchat.neurobrains.co/llms.txt
Use this file to discover all available pages before exploring further.
Overview
UserSession manages one user’s conversation state. It is created automatically when chat() is called for the first time for a given user_id + platform combination.
Access it via lc.get_session():
Attributes
The user identifier this session belongs to.
The platform namespace for this session.
In-memory list of
(user_message, ai_response) tuples. Loaded from Supabase on session creation and updated after each exchange.The LangChain chain that processes messages. Handles retrieval, reranking, prompt formatting, and LLM calling.
Methods
save_message()
Save a chat exchange to Supabase. Called automatically after chat() — you don’t need to call this manually.
Session lifecycle
- Creation — on first
chat()call for this user + platform - History loading — recent messages loaded from Supabase
- Processing — each
chat()call passes throughsession.conversation.ainvoke() - Saving — exchange saved to Supabase in background (non-blocking)
- Memory update — in-memory
chat_historyupdated - Eviction — oldest exchanges dropped when
len(chat_history) > max_chat_history
Inspecting a session
Session caching
Sessions are cached inLangChatEngine.sessions as a dict:
chat() call.