Science Infuse
Getting started

Locally

Setting up Ada

Ada's main logic consists of two components:

  1. The NextJS backend handles:

    • Database operations: Storing users, processed documents, chapters, education levels, etc.
  2. The Python backend manages:

    • The document processing pipeline

Ada is a monorepo managed by Docker Compose. Follow these steps to get the project running on your local machine.

Prerequisites

  • Git
  • conda with Python 3.9 (you can use venv)
  • npm and Node.js
  • A computer / server with CUDA 12 installed
  • Postgresql

Postgresql

You can run use the docker compose to launch an instance of postgresql

docker compose up postgresql

If you prefer to run it "locally" you can come up with your own instance, by changing the relevant environment variables

Installation

  1. Clone the repository:
git clone git@github.com:betagouv/science-infuse.git
  1. Navigate to the project directory:
cd science-infuse

The server

the server is used in two ways:

  1. To run the processing pipeline in order to index the documents (pdf, video, ...).
    It does this using the AI models that run locally
  2. To serve the embedding models, used by the web client to process every user queries.

Setup the server

  1. Create a virtual environment using conda with python 3.9
conda create --name scienceinfuse python=3.9
conda activate scienceinfuse
  1. Go inside the server folder:
cd server
  1. Install the required dependencies
pip install -r requirements.txt

Dependency missing

If when running the server, you encounter a error saying that a dependency is missing.

  1. Make sure that the requirements.txt has been installed correctly (without error)
  2. refer to the Dockerfile (server/Dockerfile) to see if a your missing dependency is not specified there (look for a RUN pip install xxx inside the Dockerfile)
  1. Make sure you have correctly set-up the environment variables

Launch the server

The server needs to access the environment variables. To inject them, you can run it with this command:

env $(grep -v '^#' ../.env | xargs) python app/main.py

This command will inject the environment variables located in the root folder's .env file into the context of the command.

The next-app

The next-app is built using the following technologies :

  • Next.JS 14 (with app router)
  • Prisma ORM used to connect to the Postgresql database.

Setup the next-app

  1. Navigate to the project directory:
cd next-app
  1. Install the required dependencies
npm install
  1. Sync the database
npx prisma db push
  1. Feed the db with initial content
npm run db:seed

Launch the next-app

npm run dev

if everything worked well you can visit http://localhost:3000/ and you should see something like this:

Image

Troubleshooting

If you encounter any issues during setup, please check the following:

  • Ensure all prerequisites are correctly installed.
  • Verify that the required ports are not being used by other applications.
  • Check the logs for any error messages.

If problems persist, please contact erwan.boehm@beta.gouv.fr or open an issue on the GitHub repository.

On this page