notSoNLPnerd commited on
Commit
e162fdc
·
1 Parent(s): 44806a2

requirements.txt

Browse files
Files changed (2) hide show
  1. app.py +20 -4
  2. requirements.txt +1 -1
app.py CHANGED
@@ -17,10 +17,6 @@ logging.basicConfig(
17
  force=True,
18
  )
19
 
20
- p_1 = None
21
- p_2 = None
22
-
23
-
24
  def get_plain_pipeline():
25
  prompt_open_ai = PromptModel(model_name_or_path="text-davinci-003", api_key=api_key)
26
 
@@ -61,11 +57,31 @@ def get_ret_aug_pipeline():
61
  return pipe
62
 
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  def app_init():
65
 
66
  os.environ["OPENAI_API_KEY"] = st.secrets["OPENAI_API_KEY"]
67
  p1 = get_plain_pipeline()
68
  p2 = get_ret_aug_pipeline()
 
69
  return p1, p2
70
 
71
 
 
17
  force=True,
18
  )
19
 
 
 
 
 
20
  def get_plain_pipeline():
21
  prompt_open_ai = PromptModel(model_name_or_path="text-davinci-003", api_key=api_key)
22
 
 
57
  return pipe
58
 
59
 
60
+ def get_web_ret_pipeline():
61
+ search_key = st.secrets["WEBRET_API_KEY"]
62
+ web_retriever = WebRetriever(api_key=search_key, search_engine_provider="SerperDev")
63
+ shaper = Shaper(func="join_documents", inputs={"documents": "documents"}, outputs=["documents"])
64
+ default_template = PromptTemplate(
65
+ name="question-answering",
66
+ prompt_text="Given the context please answer the question. Context: $documents; Question: "
67
+ "$query; Answer:",
68
+ )
69
+ # Let's initiate the PromptNode
70
+ node = PromptNode("text-davinci-003", default_prompt_template=default_template, api_key=api_key, max_length=500)
71
+ # Let's create a pipeline with Shaper and PromptNode
72
+ pipe = Pipeline()
73
+ pipe.add_node(component=web_retriever, name='retriever', inputs=['Query'])
74
+ pipe.add_node(component=shaper, name="shaper", inputs=["retriever"])
75
+ pipe.add_node(component=node, name="prompt_node", inputs=["shaper"])
76
+ return pipe
77
+
78
+
79
  def app_init():
80
 
81
  os.environ["OPENAI_API_KEY"] = st.secrets["OPENAI_API_KEY"]
82
  p1 = get_plain_pipeline()
83
  p2 = get_ret_aug_pipeline()
84
+ # p3 = get_web_ret_pipeline()
85
  return p1, p2
86
 
87
 
requirements.txt CHANGED
@@ -1 +1 @@
1
- farm-haystack -e git+https://github.com/deepset-ai/haystack.git@ffd02c29f7cc83a119b6440bfbabaacdaaac3a19
 
1
+ git+https://github.com/deepset-ai/haystack.git@ffd02c29f7cc83a119b6440bfbabaacdaaac3a19#egg=farm-haystack