- This is a simple Python/Flask service that can ingest text, convert it into embeddings, and store the embeddings within memory.
- Given a query, a relevant sentence is then returned.
- Create a virtual environment
virtualenv env
- Activate the virtual environment
source env/bin/activate
- Install the dependencies in requirements.txt
pip install -r requirements.txt
- Run the server by using the following command:
python3 server.py
- In order to ingest data, make a POST request to http://127.0.0.1:5000/ingest using JSON format in the body
curl --location 'http://127.0.0.1:5000/ingest' \
--header 'Content-Type: application/json' \
--data '[
{
"id": 1,
"text": "This is a test sentence."
}
]'
- In order to find a similar sentence, make a GET request to http://127.0.0.1:5000/query using query param "text"
curl --location 'http://127.0.0.1:5000/query?text=test%20query'
Unit tests can be found in tests.py
To run tests, use:
python3 tests.py