File size: 969 Bytes
8df121c
70b2fc9
05feb2b
 
70b2fc9
05feb2b
70b2fc9
 
 
 
 
 
 
 
91eb887
70b2fc9
8df121c
05feb2b
8df121c
 
 
 
 
 
 
 
 
 
05feb2b
 
 
 
 
 
76d2ac6
 
8df121c
05feb2b
 
8df121c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import glob
import logging
import sys

import streamlit as st
from haystack import Pipeline

logging.basicConfig(
    level=logging.DEBUG,
    format="%(levelname)s %(asctime)s %(name)s:%(message)s",
    handlers=[logging.StreamHandler(sys.stdout)],
    force=True,
)

p = None


def app_init():
    indexing_pipeline = Pipeline.load_from_yaml("pipeline.yaml", pipeline_name="indexing")
    file_paths = glob.glob("data/*")
    ds = indexing_pipeline.get_node("DocumentStore")
    ds.delete_all_documents()
    indexing_pipeline.run(file_paths=file_paths)
    ds.update_embeddings(indexing_pipeline.get_node("Retriever"))
    ds.save(config_path="my_faiss_config.json", index_path="my_faiss_index.faiss")

    global p
    p = Pipeline.load_from_yaml("pipeline.yaml", pipeline_name="query")


def main():
    app_init()
    st.title("Haystack Demo")
    input = st.text_input("Query ...")
    result = p.run(input)
    st.text()


if __name__ == "__main__":
    main()