Skip to content

Latest commit

 

History

History
289 lines (196 loc) · 5.48 KB

File metadata and controls

289 lines (196 loc) · 5.48 KB

Quick Start Guide

This guide will help you get the Clinical ChatBot up and running in 10 minutes.

Prerequisites

Make sure you have:

Step 1: Clone the Repository

cd Clinical-ChatBot

Step 2: Set Up Backend

2.1 Create Virtual Environment

cd backend
python -m venv venv

# On Windows:
venv\Scripts\activate

# On macOS/Linux:
source venv/bin/activate

2.2 Install Dependencies

pip install -r requirements.txt

2.3 Configure Environment

Create .env file:

# On Windows:
copy .env.example .env

# On macOS/Linux:
cp .env.example .env

Edit .env and add your credentials:

# OpenAI Configuration
OPENAI_API_KEY=sk-your-openai-api-key-here

# Pinecone Configuration
PINECONE_API_KEY=your-pinecone-api-key-here
PINECONE_ENVIRONMENT=us-east-1-aws
PINECONE_INDEX_NAME=clinical-chatbot

# Security (generate a random string)
SECRET_KEY=your-secret-key-here-change-in-production

2.4 Start Backend Server

python -m app.main

You should see:

INFO:     Uvicorn running on http://0.0.0.0:8000

Step 3: Set Up Frontend

Open a new terminal window:

3.1 Navigate to Frontend

cd frontend

3.2 Install Dependencies

npm install

3.3 Configure Environment

Create .env.local file:

# On Windows:
copy .env.local.example .env.local

# On macOS/Linux:
cp .env.local.example .env.local

The default configuration should work:

NEXT_PUBLIC_API_URL=http://localhost:8000

3.4 Start Frontend Server

npm run dev

You should see:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000

Step 4: Test the Application

  1. Open your browser and navigate to: http://localhost:3000

  2. You should see the Clinical AI Assistant interface

  3. Try asking a question:

    What are the common symptoms of hypertension?
    
  4. The AI will respond (without RAG if no documents are uploaded yet)

Step 5: Upload a Clinical Document (Optional)

To enable RAG with clinical documents:

  1. Prepare a PDF file with clinical content (e.g., medical guidelines)

  2. Click the upload button in the interface

  3. Select your PDF file

  4. Wait for processing (you'll see chunk count)

  5. Now ask questions related to the document content

  6. Toggle "Use RAG" to enable document-based responses

Verify Installation

Backend Health Check

Visit: http://localhost:8000/api/health

You should see:

{
  "status": "healthy",
  "version": "1.0.0",
  "pinecone_connected": true,
  "openai_connected": true
}

API Documentation

Visit: http://localhost:8000/api/docs

You'll see the interactive Swagger UI documentation.

Common Issues

Issue: Pinecone Connection Failed

Solution:

  1. Verify your Pinecone API key is correct
  2. Check the environment/region matches your Pinecone account
  3. Ensure the index name doesn't conflict with existing indexes

Issue: OpenAI API Error

Solution:

  1. Verify your OpenAI API key is correct
  2. Check you have sufficient credits in your OpenAI account
  3. Ensure you have access to GPT-4 (or change to GPT-3.5 in code)

Issue: Frontend Can't Connect to Backend

Solution:

  1. Verify backend is running on port 8000
  2. Check NEXT_PUBLIC_API_URL in .env.local
  3. Verify CORS settings in backend allow http://localhost:3000

Issue: Module Not Found Errors

Solution:

  1. Ensure virtual environment is activated (backend)
  2. Run pip install -r requirements.txt again
  3. For frontend, run npm install again

Next Steps

Now that your application is running:

  1. Upload Documents: Add clinical guidelines and reference materials
  2. Test RAG: Ask questions related to uploaded documents
  3. Explore API: Check out the API documentation
  4. Run Tests: Execute pytest in backend, npm test in frontend
  5. Customize: Modify the theme, prompts, or add features

Running Tests

Backend Tests

cd backend
pytest

Expected output:

===== test session starts =====
collected 20 items

tests/test_rag_engine.py ............ [60%]
tests/test_document_processor.py .... [80%]
tests/test_api_chat.py .... [100%]

===== 20 passed in 5.23s =====

Frontend Tests

cd frontend
npm test

Docker Deployment (Optional)

If you prefer Docker:

# From project root
docker-compose up

This will start both backend and frontend in containers.

Production Considerations

Before deploying to production:

  1. Security:

    • Change SECRET_KEY to a strong random value
    • Use HTTPS
    • Implement authentication
    • Set up rate limiting
  2. Environment:

    • Set APP_ENV=production
    • Configure proper CORS origins
    • Set up logging
  3. Performance:

    • Use production build for frontend (npm run build)
    • Consider Redis for conversation memory
    • Set up CDN for static assets
  4. Monitoring:

    • Set up error tracking (e.g., Sentry)
    • Configure logging
    • Monitor API usage

Getting Help

  • Check the README.md for detailed documentation
  • Review ARCHITECTURE.md for system design
  • Check API docs at http://localhost:8000/api/docs
  • Review error logs for debugging

Success!

You now have a fully functional Clinical AI ChatBot running locally! 🎉

Start chatting with the AI assistant and explore its capabilities.