Haystack: Build simple Streamlit UI

Created on 8 Dec 2020  路  6Comments  路  Source: deepset-ai/haystack

Is your feature request related to a problem? Please describe.
For a fast proof of concepts users need to try Haystack on their own documents. While this is possible on the code level (e.g. Tutorial 1), in many cases an additional UI would be helpful so that users can interact more easily with the model and show it to colleagues.

Describe the solution you'd like
A minimal UI built with streamlit (https://www.streamlit.io/):

  • user enters query in search bar
  • UI calls Haystack REST API which runs separately
  • search results are shown in the UI (passage incl. highlighted answer string)

Describe alternatives you've considered
At the moment users do the Proof of concept just on the code level OR build their own custom UIs OR use Haystack Hub

enhancement good first issue

Most helpful comment

@demarant looks great! Thanks for sharing!

How about combing your app elements with the one @tanmaylaud started in #671?

What I could imagine is for example integrating your "answer list" (incl. highlighting), the docker image and "debug info" into #671.
What do you think @tanmaylaud?

All 6 comments

@tholor , i can help with creation of the UI, if a demo backend is already setup.
I have created a streamlit dashboard already for one of our projects.

@tanmaylaud This would be amazing!

I would suggest using the existing backend. You can see the fastAPI definition of the REST API here: https://github.com/deepset-ai/haystack/tree/master/rest_api

For instructions to run it see the readme section

OR you use our docker images via the docker-compose.yml (they start the API automatically)

For running a basic QA search, you can then call:

curl --request POST --url 'http://127.0.0.1:8000/models/1/doc-qa' --data '{"questions": ["Who is the father of Arya Starck?"]}'

Let me know if you need any further support along the way! Happy to help :)

@tholor
I made one streamlit app against haystack demo API

Type your question about "financial matter" and get an answer as below :)

haystack-streamlit

code on gist
https://gist.github.com/demarant/d9e617fb80057692f2f7cddf00013b9b
download it locally and run it easily via streamlit docker image

sudo docker run -p 8888:8888 -v ~/projects/streamlit:/app eeacms/streamlit-base ./haystack-demo.py

make sure to place the haystack-demo.py inside the localfolder ~/projects/streamlit

In the left panel it has some basic options as number of answers to be displayed and debug info. You could add more settings there.

here the eeacms/streamlit-base dockerfile

you can modify it to use another API backend (e.g. localhost or passed by environment variable) and add it in the docker-compose of the haystack.

@demarant looks great! Thanks for sharing!

How about combing your app elements with the one @tanmaylaud started in #671?

What I could imagine is for example integrating your "answer list" (incl. highlighting), the docker image and "debug info" into #671.
What do you think @tanmaylaud?

@tholor yes that sounds great !
Liked the highlighting part .
@demarant let me know if any help needed.

@tholor @tanmaylaud just curious how about having two demos via streamlit -

  • Haystack Rest API demo
  • Haystack as SDK (showing power of pipeline and other features like generator, reader, etc)

Idea is to make all classes as dataclass (or via to_dict and from_dict methods ) and when user select feature like (generator, reader, retriever etc) from sidebar, it automatically refresh sidebar with all class variables based on data type like if str then text field, bool then option or checkbox, List then dropdown list, etc.

Mainly current rest APIs only shows limited capabilities of Haystack can achieve.

Was this page helpful?
0 / 5 - 0 ratings