Skip to content

stage4(sagemaker-deployment): Chat Persistence, History, Eviction, Delete Endpoint, Tests & Demo Description - #7

Merged
shreyashx16 merged 6 commits into
mainfrom
stage4/sagemaker-deployment
Mar 3, 2026
Merged

stage4(sagemaker-deployment): Chat Persistence, History, Eviction, Delete Endpoint, Tests & Demo Description#7
shreyashx16 merged 6 commits into
mainfrom
stage4/sagemaker-deployment

Conversation

@shreyashx16

@shreyashx16 shreyashx16 commented Oct 27, 2025

Copy link
Copy Markdown
Owner

Description - Fixes #6

Summary
This PR completes the Stage 4 features by adding persistent chat session management, including session history, TTL-based eviction, and a safe delete endpoint. It also adds the necessary tests, a small demo script, and updates to the README to ensure the app can be easily run and demoed locally. This work is hackathon-ready and fully tested.

Key Changes

  • Persistence

    • Added chat session management functions: init_chat_db, save_session, load_session, delete_session, and list_sessions.
    • Chat session persistence is SQLite-based, and the database path can be dynamically set via the CHAT_DB environment variable.
  • Chat API & Session Management

    • POST /chat: Creates or continues a session. Saves sessions after each message.
    • GET /chat/{session_id}/history: Retrieves chat history for a session (in-memory or persisted).
    • DELETE /chat/{session_id}: Deletes a session from both memory and persistence.
    • Eviction: Periodic background eviction of expired sessions, triggered based on CHAT_SESSION_TTL_SECONDS and CHAT_EVICT_INTERVAL_SECONDS.
  • Tests

    • Added tests for chat history retrieval, session persistence, delete functionality, and TTL-based eviction.
  • Docs & Demo

    • Updated README with instructions on setting up environment variables and running the demo.
    • Added demo_demo.py to simulate upload, analysis, chat, and history operations.

How to Run Locally

  1. Install Dependencies

    python -m venv .venv
    pip install -r requirements.txt
  2. Run Tests

    $env:PYTHONPATH='.'; pytest -q
  3. Start the Server

    uvicorn app.app:app --reload --host 0.0.0.0 --port 8000
  4. Run the Demo

    python demo_demo.py
  5. Access Interactive API Docs
    http://127.0.0.1:8000/docs

Environment Variables

  • CHAT_DB — Path to SQLite DB for chat sessions (default: sessions.db).
  • CHAT_SESSION_TTL_SECONDS — Session TTL in seconds (default: 3600). Set <= 0 to disable expiry.
  • CHAT_CONTEXT_TURNS — Number of turns to include in the LLM prompt (default: 10).
  • CHAT_EVICT_INTERVAL_SECONDS — Background eviction interval (default: 60).

Next Steps

  • Add AWS client wrappers for SageMaker integration.
  • Teach KnowledgeStore to use SageMaker embeddings with fallback options.
  • Add a CI job to mock AWS/SageMaker interactions.
  • Optional: Implement Redis-backed session store (for multi-instance environments).

PR Checklist:

  • Added chat session persistence with SQLite.
  • Implemented /chat/{session_id}/history and /chat/{session_id}/delete endpoints.
  • Added background session eviction (TTL-based).
  • Added tests for chat functionality (history, persistence, TTL eviction, delete).
  • Updated README with setup instructions and environment variables.
  • Added demo script for showcasing functionality.

@github-actions

Copy link
Copy Markdown

CodeGuardian scan — no results found

@github-actions

Copy link
Copy Markdown

CodeGuardian scan — no results found

@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown

CodeGuardian scan — no results found

@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown

CodeGuardian scan — no results found

@shreyashx16
shreyashx16 merged commit 32e4d9a into main Mar 3, 2026
6 of 7 checks passed
@shreyashx16
shreyashx16 deleted the stage4/sagemaker-deployment branch March 3, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue: Stage 4 – Integrate AWS SageMaker & NVIDIA NIM Services

1 participant