This folder contains an example of how to use Docker Compose to orchestrate a simple web application serving two Haystack pipelines using Hayhooks, one for indexing documents and a second to query them, using Qdrant for storage and retrieval.
To jump straight into running the demo, clone this repo and cd into the current folder:
git clone https://github.com/deepset-ai/haystack-demos.git
cd haystack-demos/qdrant_indexingWe have implemented two pipeline wrappers in the ./pipelines folder:
qdrant_indexing: This pipeline is used to index documents into Qdrant.qdrant_query: This pipeline is used to query documents from Qdrant.
They will be automatically loaded by Hayhooks when the server starts.
Run this command to pull the Qdrant Docker image, build the one defined by this demo and run both of them:
docker-compose up
# or, if you want to run the containers in the background
docker-compose up -dEventually, you should have two containers running: qdrant for the local Qdrant instance and hayhooks. Check it out by running:
docker-compose psCheck if the Hayhooks server is running by going to http://localhost:1416/docs in your browser.
You should also see the documentation for the two pipelines under the pipelines section of docs:
To better understand what the two pipelines do, you can visualize their graph using the /draw/ endpoint. For example,
to visualize qdrant_indexing you can point your browser to
http://localhost:1416/draw/qdrant_indexing.
You have two ways to interact with the pipelines:
- Using the Hayhooks CLI
- Using the Hayhooks API
To index a file containing some text, we can make a POST request to the /qdrant_indexing endpoint:
curl -X POST http://localhost:1416/qdrant_indexing/run -F "files=@test_file.txt"Upon a successful request, you should get the following JSON response:
{
"result": {
"success":true
}
}To use the Hayhooks CLI, you need to install hayhooks first:
pip install hayhooksThen you can run:
hayhooks pipeline run qdrant_indexing --file test_file.txtThis will run the qdrant_indexing pipeline with test_file.txt and index the text into Qdrant
Similarly to indexing, we can query our data by making a POST request to the /qdrant_query/run endpoint:
curl -X "POST" "http://localhost:1416/qdrant_query/run" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{ "query": "GitHub" }'The response should be something like:
{
"result": {
"retriever": {
"documents": [
{
"id": "6b2aec5ac2978cf866a5f27c8fc92e7b06eb9742096093ca238a1fb8309cf139",
"content": "Alerts are an extension of Markdown used to emphasize critical information. On GitHub, they are displayed with distinctive colors and icons to indicate the importance of the content.",
// ...
}
]
}
}
}You'll need to install hayhooks first:
pip install hayhooksThen you can run:
hayhooks pipeline run qdrant_query --param 'query="Github"'Happy Hacking!
