cvpaperchallenge / Crux

Crux is a suite of LLM-empowered summarization and retrieval services for academic activity. Crux is developed by XCCV group of cvpaper.challenge.
MIT License
14 stars 2 forks source link

Enhancement/save chat history #33

Closed YoshikiKubotani closed 3 months ago

YoshikiKubotani commented 3 months ago

Issue URL

N/A

Change overview

How to test

[!Important] The following test CANNOT BE DONE if you are not an authorized member of cvpaper challenge who does not have access to the Amazon Secret Manager of our organization.

1. Prerequisite

  1. Prepare the API keys for OpenAI API

  2. Create your own environments/.env referring environments/.env.sample and specify the secret environment variables

    • You might be able to get AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY by asking for them to @gatheluck who manages the AWS account I used for the Crux application
    • You can get AWS_DEFAULT_REGION and DYNAMODB_TABLE_NAME from here
    • You can get QDRANT_CLOUD_URL and QDRANT_API_KEY from here. If you want to use the different Qdrant Cloud cluster from one I prepared and try to test vector registration
    OPENAI_API_KEY=<PLEASE_WRITE_YOUR_OPEN_API_KEY_HERE>
    
    # AWS service settings
    AWS_ACCESS_KEY_ID=<PLEASE_WRITE_YOUR_AWS_ACCESS_KEY_ID_HERE>
    AWS_SECRET_ACCESS_KEY=<PLEASE_WRITE_YOUR_AWS_SECRET_ACCESS_KEY_HERE>
    AWS_DEFAULT_REGION=<PLEASE_WRITE_YOUR_AWS_DEFAULT_REGION_HERE>
    DYNAMODB_TABLE_NAME=<PLEASE_WRITE_YOUR_DYNAMODB_TABLE_NAME_HERE>
    
    # Qdrant cloud settings
    QDRANT_CLOUD_URL=<PLEASE_WRITE_YOUR_QDRANT_CLOUD_URL_HERE>
    QDRANT_API_KEY=<PLEASE_WRITE_YOUR_QDRANT_API_KEY_HERE>

2. Local Test

Due to modifications to the Dockerfile, it is necessary to restart the container once.

  1. Remove the existing containers

    # Move to the directory that has `docker-compose.yaml`
    ~/Crux$ cd environments/cpu
    
    # Remove the existing docker containers
    ~/Crux/environments/cpu$ docker compose down
  2. Boot up containers without using cache

    # Re-build docker images without using cache
    ~/Crux/environments/cpu$ docker compose build --no-cache
    
    # Boot up docker containers
    ~/Crux/environments/cpu$ docker compose up -d

Run the backend logic on the local server

  1. Update Python libraries inside the backend container

    # Update the poetry.lock and install the updated Python libraries
    ~/crux-backend$ poetry update
  2. Run the backend server

    ~/crux-backend$ poetry run make run-backend
    
    poetry run gunicorn 'src.main:app' -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000 -t 6000 --log-level info
    [2024-05-19 02:21:02 +0000] [3866] [INFO] Starting gunicorn 21.2.0
    [2024-05-19 02:21:02 +0000] [3866] [INFO] Listening at: http://0.0.0.0:8000 (3866)
    [2024-05-19 02:21:02 +0000] [3866] [INFO] Using worker: uvicorn.workers.UvicornWorker
    [2024-05-19 02:21:02 +0000] [3882] [INFO] Booting worker with pid: 3882
    [2024-05-19 02:21:03 +0000] [3882] [INFO] Started server process [3882]
    [2024-05-19 02:21:03 +0000] [3882] [INFO] Waiting for application startup.
    [2024-05-19 02:21:03 +0000] [3882] [INFO] Application startup complete.

Run the frontend UI on the local server

  1. Install node.js libraries inside the frontend container

    # Move to the frontend directory
    ~/crux-frontend$ cd crux
    # Install node.js dependencies
    ~/crux-frontend$ npm install
  2. Run the frontend server

    # Run the server
    ~/crux-frontend/crux$ npm run dev
    
    > crux@0.1.0 dev
    > next dev
    
       ▲ Next.js 14.1.4
       - Local:        http://localhost:3000
      - Environments: .env.development, .env
    
     ✓ Ready in 2.9s
     ○ Compiling / ...
     ✓ Compiled / in 4.7s (3100 modules)
     ✓ Compiled in 1676ms (1540 modules)
  3. Make sure the Crux application is displayed correctly on http://localhost:3000

    image

Test the application

  1. Log in to the application from the "Login" button.

    Please use the email and password registered here image

    You will be redirected to the following page after login. image

    You can create/delete/list chats on that page.

Note for reviewers

[!Note] There may be some errors in frontend UI logic