Skip to content

Latest commit

 

History

History
85 lines (57 loc) · 2.27 KB

USAGE.md

File metadata and controls

85 lines (57 loc) · 2.27 KB

Running and testing the API locally

With your local environment

Create and set the environment variables based on .env.template. You will need to create a .env file.

Running

flask run -h 0.0.0.0 --debug

Alternatively, set the FINESSE_BACKEND_DEBUG_MODE environment variable to True and run:

python run.py

With docker

Create and set the environment variables based on .env.template. You will need to create a .env file.

Build the container:

docker build -t finesse-backend .

Deploy the container locally:

docker run -p 5000:5000 -e PORT=5000 --env-file .env finesse-backend

Docker-compose (optional)

You can also use docker-compose to run the API with the client. The client is the web interface that makes use of the API and is available at https://github.com/ai-cfia/finesse-frontend.

To run the API and the client together, you can use the following command:

docker-compose up --build

You can then access the client at http://localhost.

Check if the API is working properly

Test the path: /search/static

curl -X POST http://localhost:5000/search/static --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json"

Test the path: /search/azure

curl -X POST "http://localhost:5000/search/azure?top=10&skip=0" --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json"
  • top (optional): Number of search results to return.
  • skip (optional): Number of search results to skip from the start.

Test the path: /search/llamaindex

curl -X POST "http://localhost:5000/search/llamaindex?top=10" --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json"
  • top (optional): Number of search results to return.

JSON structure explanation

  • id: The unique identifier for each document.
  • url: The URL of the document, which should point to inspection.canada.ca.
  • score: Represents the search score, indicating the relevance of the document to the query.
  • title: The title of the document.
  • content: The main content or body of the document.
  • subtitle: The title or titles extracted from the snippet.
  • last_updated: The last modified date of the document.