merve HF staff commited on
Commit
35b16cf
1 Parent(s): 391c720

Update utils/haystack.py

Browse files
Files changed (1) hide show
  1. utils/haystack.py +3 -3
utils/haystack.py CHANGED
@@ -8,9 +8,9 @@ from haystack.nodes import PromptNode, PromptTemplate
8
  @st.cache(
9
  hash_funcs={"builtins.SwigPyObject": lambda _: None}, allow_output_mutation=True
10
  )
11
- def start_haystack():
12
  #Use this function to contruct a pipeline
13
- prompt_node = PromptNode(model_name_or_path="text-davinci-003", api_key=OEPN_AI_KEY)
14
 
15
  twitter_template = PromptTemplate(name="twitter-voice", prompt_text="""You will be given a twitter stream belonging to a specific profile. Answer with a summary of what they've lately been tweeting about and in what languages.
16
  You may go into some detail about what topics they tend to like tweeting about. Please also mention their overall tone, for example: positive,
@@ -39,7 +39,7 @@ def start_haystack():
39
  """)
40
  return prompt_node, twitter_template
41
 
42
- prompter, template = start_haystack()
43
 
44
  @st.cache(show_spinner=False, allow_output_mutation=True)
45
  def query(username):
 
8
  @st.cache(
9
  hash_funcs={"builtins.SwigPyObject": lambda _: None}, allow_output_mutation=True
10
  )
11
+ def start_haystack(openai_key):
12
  #Use this function to contruct a pipeline
13
+ prompt_node = PromptNode(model_name_or_path="text-davinci-003", api_key=openai_key)
14
 
15
  twitter_template = PromptTemplate(name="twitter-voice", prompt_text="""You will be given a twitter stream belonging to a specific profile. Answer with a summary of what they've lately been tweeting about and in what languages.
16
  You may go into some detail about what topics they tend to like tweeting about. Please also mention their overall tone, for example: positive,
 
39
  """)
40
  return prompt_node, twitter_template
41
 
42
+ prompter, template = start_haystack(openai_key)
43
 
44
  @st.cache(show_spinner=False, allow_output_mutation=True)
45
  def query(username):