Spaces:
Runtime error
Runtime error
oryx1729
commited on
Commit
•
0b1473d
1
Parent(s):
76d2ac6
Changes
Browse files- app.py +26 -5
- faiss_document_store.db +0 -0
- pipeline.yaml +13 -4
app.py
CHANGED
@@ -12,7 +12,8 @@ logging.basicConfig(
|
|
12 |
force=True,
|
13 |
)
|
14 |
|
15 |
-
|
|
|
16 |
|
17 |
|
18 |
def app_init():
|
@@ -24,16 +25,36 @@ def app_init():
|
|
24 |
ds.update_embeddings(indexing_pipeline.get_node("Retriever"))
|
25 |
ds.save(config_path="my_faiss_config.json", index_path="my_faiss_index.faiss")
|
26 |
|
27 |
-
global
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
def main():
|
32 |
app_init()
|
33 |
st.title("Haystack Demo")
|
34 |
input = st.text_input("Query ...")
|
35 |
-
|
36 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
|
39 |
if __name__ == "__main__":
|
|
|
12 |
force=True,
|
13 |
)
|
14 |
|
15 |
+
p_1 = None
|
16 |
+
p_2 = None
|
17 |
|
18 |
|
19 |
def app_init():
|
|
|
25 |
ds.update_embeddings(indexing_pipeline.get_node("Retriever"))
|
26 |
ds.save(config_path="my_faiss_config.json", index_path="my_faiss_index.faiss")
|
27 |
|
28 |
+
global p_1
|
29 |
+
p_1 = Pipeline.load_from_yaml("pipeline.yaml", pipeline_name="query_1")
|
30 |
+
|
31 |
+
global p_2
|
32 |
+
p_2 = Pipeline.load_from_yaml("pipeline.yaml", pipeline_name="query_2")
|
33 |
|
34 |
|
35 |
def main():
|
36 |
app_init()
|
37 |
st.title("Haystack Demo")
|
38 |
input = st.text_input("Query ...")
|
39 |
+
|
40 |
+
query_type = st.radio("Type",
|
41 |
+
("Retrieval Augmented", "Retrieval Augmented with Sources",
|
42 |
+
"Retrieval Augmented with Web Search"))
|
43 |
+
|
44 |
+
|
45 |
+
col_1, col_2 = st.columns(2)
|
46 |
+
|
47 |
+
with col_1:
|
48 |
+
st.text("PLAIN")
|
49 |
+
answers = p_1.run(input)["answers"]
|
50 |
+
for ans in answers:
|
51 |
+
st.text(ans.answer)
|
52 |
+
|
53 |
+
with col_2:
|
54 |
+
st.write(query_type.upper())
|
55 |
+
answers = p_2.run(input)["answers"]
|
56 |
+
for ans in answers:
|
57 |
+
st.text(ans.answer)
|
58 |
|
59 |
|
60 |
if __name__ == "__main__":
|
faiss_document_store.db
CHANGED
Binary files a/faiss_document_store.db and b/faiss_document_store.db differ
|
|
pipeline.yaml
CHANGED
@@ -20,22 +20,31 @@ components:
|
|
20 |
frequency_penalty: 0.1 # Positive values penalize new tokens based on their existing frequency in the text so far.
|
21 |
presence_penalty: 0.1 # Positive values penalize new tokens based on whether they have already appeared in the text.
|
22 |
top_k: 3 # The number of results to return
|
|
|
23 |
|
24 |
- name: TextFileConverter
|
25 |
type: TextConverter
|
26 |
pipelines:
|
27 |
-
- name:
|
28 |
nodes:
|
29 |
- inputs: [Query]
|
30 |
name: Retriever
|
31 |
- inputs: [Retriever]
|
32 |
name: PromptNode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
- name: indexing
|
34 |
nodes:
|
35 |
- name: TextFileConverter
|
36 |
-
inputs: [File]
|
37 |
- name: Retriever
|
38 |
-
inputs: [TextFileConverter]
|
39 |
- name: DocumentStore
|
40 |
-
inputs: [Retriever]
|
41 |
version: ignore
|
|
|
20 |
frequency_penalty: 0.1 # Positive values penalize new tokens based on their existing frequency in the text so far.
|
21 |
presence_penalty: 0.1 # Positive values penalize new tokens based on whether they have already appeared in the text.
|
22 |
top_k: 3 # The number of results to return
|
23 |
+
api_key: "loaded-from-env"
|
24 |
|
25 |
- name: TextFileConverter
|
26 |
type: TextConverter
|
27 |
pipelines:
|
28 |
+
- name: query_1
|
29 |
nodes:
|
30 |
- inputs: [Query]
|
31 |
name: Retriever
|
32 |
- inputs: [Retriever]
|
33 |
name: PromptNode
|
34 |
+
|
35 |
+
- name: query_2
|
36 |
+
nodes:
|
37 |
+
- inputs: [ Query ]
|
38 |
+
name: Retriever
|
39 |
+
- inputs: [ Retriever ]
|
40 |
+
name: PromptNode
|
41 |
+
|
42 |
- name: indexing
|
43 |
nodes:
|
44 |
- name: TextFileConverter
|
45 |
+
inputs: [ File ]
|
46 |
- name: Retriever
|
47 |
+
inputs: [ TextFileConverter ]
|
48 |
- name: DocumentStore
|
49 |
+
inputs: [ Retriever ]
|
50 |
version: ignore
|