{"id":18395843,"url":"https://github.com/deepset-ai/haystack-search-pipeline-streamlit","last_synced_at":"2025-07-06T19:38:44.750Z","repository":{"id":173390603,"uuid":"578688096","full_name":"deepset-ai/haystack-search-pipeline-streamlit","owner":"deepset-ai","description":"🚀 Template Haystack Search Application with Streamlit","archived":false,"fork":false,"pushed_at":"2025-01-16T18:12:10.000Z","size":63,"stargazers_count":27,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-22T13:22:30.091Z","etag":null,"topics":["haystack","nlp","python","streamlit"],"latest_commit_sha":null,"homepage":"https://haystack.deepset.ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepset-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-15T16:39:50.000Z","updated_at":"2025-02-16T13:24:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d3e805e-7bab-4afa-96e5-4100e9e21fdd","html_url":"https://github.com/deepset-ai/haystack-search-pipeline-streamlit","commit_stats":null,"previous_names":["deepset-ai/haystack-search-pipeline-streamlit"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepset-ai%2Fhaystack-search-pipeline-streamlit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepset-ai%2Fhaystack-search-pipeline-streamlit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepset-ai%2Fhaystack-search-pipeline-streamlit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepset-ai%2Fhaystack-search-pipeline-streamlit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepset-ai","download_url":"https://codeload.github.com/deepset-ai/haystack-search-pipeline-streamlit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247589793,"owners_count":20963022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haystack","nlp","python","streamlit"],"created_at":"2024-11-06T02:12:09.645Z","updated_at":"2025-04-07T03:35:13.391Z","avatar_url":"https://github.com/deepset-ai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: Haystack Search Pipeline with Streamlit\nemoji: 👑\ncolorFrom: indigo\ncolorTo: indigo\nsdk: streamlit\nsdk_version: 1.23.0\napp_file: app.py\npinned: false\n---\n\n# Template Streamlit App for Haystack Search Pipelines\n\n\n\u003e [!WARNING]\n\u003e **This template is for Haystack version 1.x**. Use this template: [Haystack Streamlit App](https://github.com/deepset-ai/haystack-streamlit-app) for Haystack 2.x applications. \n\nThis template [Streamlit](https://docs.streamlit.io/) app set up for simple [Haystack search applications](https://docs.haystack.deepset.ai/docs/semantic_search). The template is ready to do QA with **Retrievel Augmented Generation**, or **Extractive QA**\n\nSee the ['How to use this template'](#how-to-use-this-template) instructions below to create a simple UI for your own Haystack search pipelines.\n\nBelow you will also find instructions on how you could [push this to Hugging Face Spaces 🤗](#pushing-to-hugging-face-spaces-).\n\n## Installation and Running\nTo run the bare application which does _nothing_:\n1. Install requirements: `pip install -r requirements.txt`\n2. Run the streamlit app: `streamlit run app.py`\n\nThis will start up the app on `localhost:8501` where you will find a simple search bar. Before you start editing, you'll notice that the app will only show you instructions on what to edit.\n\n### Optional Configurations\n\nYou can set optional cofigurations to set the:\n-  `--task` you want to start the app with: `rag` or `extractive` (default: rag)\n-  `--store` you want to use: `inmemory`, `opensearch`, `weaviate` or `milvus` (default: inmemory)\n-  `--name` you want to have for the app. (default: 'My Search App')\n\nE.g.:\n\n```bash\nstreamlit run app.py -- --store opensearch --task extractive --name 'My Opensearch Documentation Search'\n```\n\nIn a `.env` file, include all the config settings that you would like to use based on:\n- The DocumentStore of your choice\n- The Extractive/Generative model of your choice\n\nWhile the `/utils/config.py` will create default values for some configurations, others have to be set in the `.env` such as the `OPENAI_KEY`\n\nExample `.env`\n\n```\nOPENAI_KEY=YOUR_KEY\nEMBEDDING_MODEL=sentence-transformers/all-MiniLM-L12-v2\nGENERATIVE_MODEL=text-davinci-003\n```\n\n\n## How to use this template\n1. Create a new repository from this template or simply open it in a codespace to start playing around 💙\n2. Make sure your `requirements.txt` file includes the Haystack and Streamlit versions you would like to use.\n3. Change the code in `utils/haystack.py` if you would like a different pipeline.\n4. Create a `.env`file with all of your configuration settings.\n5. Make any UI edits you'd like to and [share with the Haystack community](https://haystack.deepeset.ai/community)\n6. Run the app as show in [installation and running](#installation-and-running)\n\n### Repo structure\n- `./utils`: This is where we have 3 files: \n    - `config.py`: This file extracts all of the configuration settings from a `.env` file. For some config settings, it uses default values. An example of this is in [this demo project](https://github.com/TuanaCelik/should-i-follow/blob/main/utils/config.py).\n    - `haystack.py`: Here you will find some functions already set up for you to start creating your Haystack search pipeline. It includes 2 main functions called `start_haystack()` which is what we use to create a pipeline and cache it, and `query()` which is the function called by `app.py` once a user query is received.\n    - `ui.py`: Use this file for any UI and initial value setups.\n- `app.py`: This is the main Streamlit application file that we will run. In its current state it has a simple search bar, a 'Run' button, and a response that you can highlight answers with.\n\n### What to edit?\nThere are default pipelines both in `start_haystack_extractive()` and `start_haystack_rag()`\n\n- Change the pipelines to use the embedding models, extractive or generative models as you need.\n- If using the `rag` task, change the `default_prompt_template` to use one of our available ones on [PromptHub](https://prompthub.deepset.ai) or create your own `PromptTemplate`\n\n\n## Pushing to Hugging Face Spaces 🤗\n\nBelow is an example GitHub action that will let you push your Streamlit app straight to the Hugging Face Hub as a Space.\n\nA few things to pay attention to:\n\n1. Create a New Space on Hugging Face with the Streamlit SDK.\n2. Create a Hugging Face token on your HF account.\n3. Create a secret on your GitHub repo called `HF_TOKEN` and put your Hugging Face token here.\n4. If you're using DocumentStores or APIs that require some keys/tokens, make sure these are provided as a secret for your HF Space too!\n5. This readme is set up to tell HF spaces that it's using streamlit and that the app is running on `app.py`, make any changes to the frontmatter of this readme to display the title, emoji etc you desire.\n6. Create a file in `.github/workflows/hf_sync.yml`. Here's an example that you can change with your own information, and an [example workflow](https://github.com/TuanaCelik/should-i-follow/blob/main/.github/workflows/hf_sync.yml) working for the [Should I Follow demo](https://huggingface.co/spaces/deepset/should-i-follow)\n\n```yaml\nname: Sync to Hugging Face hub\non:\n  push:\n    branches: [main]\n\n  # to run this workflow manually from the Actions tab\n  workflow_dispatch:\n\njobs:\n  sync-to-hub:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n        with:\n          fetch-depth: 0\n          lfs: true\n      - name: Push to hub\n        env:\n          HF_TOKEN: ${{ secrets.HF_TOKEN }}\n        run: git push --force https://{YOUR_HF_USERNAME}:$HF_TOKEN@{YOUR_HF_SPACE_REPO} main\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepset-ai%2Fhaystack-search-pipeline-streamlit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepset-ai%2Fhaystack-search-pipeline-streamlit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepset-ai%2Fhaystack-search-pipeline-streamlit/lists"}