ShadAI Framework
  1. guides
ShadAI Framework
  • Index
  • README
  • Pricing
    • Pricing Plan
  • advanced
    • Best Practices
    • Tool Orchestration
    • Performance Optimization
    • Custom Tools
  • examples
    • Advanced Patterns
    • Custom Agent Examples
    • Market Research Examples
    • Multi-Document Analysis
    • Basic Query Examples
  • api-reference
    • Exceptions Reference
    • Engine Tool API
    • Shadai Client API Reference
    • Query Tool API
    • Summarize Tool API
    • Agent Tool API
    • Web Search Tool API
  • use-cases
    • Knowledge Synthesis
    • Research Assistant
    • Custom Workflows
    • Document Q&A
  • core-concepts
    • Architecture
    • Intelligent Agent
    • RAG System
    • Tools Overview
  • guides
    • Memory & Context
    • Streaming Responses
    • File Ingestion
    • Error Handling
    • Session Management
  • getting-started
    • Authentication
    • Your First Query
    • Quick Start
    • Installation
  1. guides

Session Management

Session Management#

Sessions are the foundation of Shadai. They organize your documents, maintain conversation context, and enable powerful multi-document workflows.

What is a Session?#

A session is a container that holds:
πŸ“š Documents - Your ingested files
πŸ’¬ Chat history - All questions and answers
🧠 Context - Conversation memory
βš™οΈ Configuration - Session-specific settings
Think of a session as a workspace for a specific project or topic.

Session Types#

Named Sessions (Persistent)#

Perfect for ongoing projects:
Use named sessions when:
Working on ongoing projects
Building up knowledge over time
Need to preserve history
Collaborating with team members

Temporal Sessions (Auto-Delete)#

Perfect for one-off queries:
Use temporal sessions when:
One-time queries
Testing or experiments
Privacy-sensitive data
No need to persist data

Creating Sessions#

Basic Session Creation#

Session Naming Best Practices#

βœ… Good Names:
❌ Bad Names:

Model Configuration#

You can configure which LLM and embedding models your session uses. This allows you to choose the best model for your specific use case based on performance, cost, and capabilities.

Specifying Models#

Available Models#

LLM Models (31 options):
OpenAI: GPT-5, GPT-4.1, GPT-4o series
Azure: Same models via Azure deployment
Anthropic: Claude Sonnet 4.5, Claude Opus 4, Claude Haiku 3.5
Google: Gemini 2.5 Pro, Gemini 2.0 Flash series
Embedding Models (5 options):
OpenAI: text-embedding-3-large, text-embedding-3-small
Azure: Same embeddings via Azure
Google: gemini-embedding-001
See complete model list β†’

Model Selection Examples#

Cost-Effective Setup#

Premium Performance#

Creative Tasks#

Mixed Providers#

Enterprise (Azure)#

System Prompts#

Customize your session's behavior with system prompts:

Model Selection Best Practices#

Choose your LLM based on:
Task complexity: GPT-4o/Claude Opus for complex reasoning, Gemini Flash for simple tasks
Speed requirements: Gemini Flash models are fastest
Cost constraints: Google models generally most cost-effective
Specific capabilities: Claude for creative work, GPT-4 for technical analysis
Choose your embedding model based on:
Quality needs: text-embedding-3-large for best retrieval accuracy
Speed/cost: text-embedding-3-small or Gemini embeddings for efficiency
Provider alignment: Match with your LLM provider when possible
System prompt tips:
Be specific about role and expertise
Include output format preferences
Mention any constraints or guidelines
Keep it concise but comprehensive

Session Lifecycle#

1. Session Creation#

What happens:
πŸ” Checks if session exists
✨ Creates new if doesn't exist
πŸ“‚ Loads existing data if exists

2. Adding Documents#

Documents are cumulative - new ingestions add to existing documents.

3. Querying#

Each query:
Searches ALL documents in session
Maintains conversation history
Updates context

4. Session Cleanup#

Working with Multiple Sessions#

Pattern 1: Sequential Processing#

Pattern 2: Parallel Processing#

Pattern 3: Hierarchical Sessions#

Session Management Operations#

Get Session History#

Response format:

Clear Session History#

Important: This clears chat history but keeps documents!

Pagination Example#

Memory Management#

Memory Enabled (Default)#

Memory Disabled#

Use use_memory=False when:
Queries are completely independent
Want to avoid context pollution
Testing specific prompts

Best Practices#

βœ… Do This#

❌ Don't Do This#

Common Patterns#

Pattern: Session Per Project#

Pattern: Session Per User#

Pattern: Session Per Topic#

Troubleshooting#

Session Not Found#

Lost Session Data#

If using temporal sessions, data is deleted on exit:

Memory Overflow#

If conversation history gets too long:

Next Steps#

Memory & Context - Deep dive into conversation memory
File Ingestion - Advanced document processing
Performance Optimization - Scale your sessions

Questions? Check out the API Reference for complete documentation.
Modified atΒ 2025-10-21 05:35:09
Previous
Error Handling
Next
Authentication
Built with