mtyrrell commited on
Commit
be11444
1 Parent(s): ff23eb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -161,13 +161,13 @@ def get_prompt(docs, input_query):
161
  prompt = base_prompt+"; Context: "+context+"; Question: "+input_query+"; Answer:"
162
  return(prompt)
163
 
164
- def run_query(input_query, country, model_sel):
165
  # docs = get_docs(input_text, country)
166
- docs = get_docs(input_query, country=country,vulnerability_cat=vulnerability_options)
167
  # st.write('Selected country: ', country) # Debugging country
168
  if model_sel == "chatGPT":
169
  # res = pipe.run(query=input_text, documents=docs)
170
- res = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": get_prompt(docs, input_query)}])
171
  output = res.choices[0].message.content
172
  references = get_refs(docs, output)
173
  # else:
@@ -263,13 +263,13 @@ else:
263
 
264
 
265
  if selected_example == "-":
266
- input_query = st.text_area('Enter your question in the text box below using natural language or select an example from above:')
267
  else:
268
- input_query = st.text_area('Enter your question in the text box below using natural language or select an example from above:', value=selected_example)
269
 
270
 
271
  if st.button('Submit'):
272
- run_query(input_query, country=country, model_sel=model_sel)
273
 
274
 
275
 
 
161
  prompt = base_prompt+"; Context: "+context+"; Question: "+input_query+"; Answer:"
162
  return(prompt)
163
 
164
+ def run_query(input_text, country, model_sel):
165
  # docs = get_docs(input_text, country)
166
+ docs = get_docs(input_text, country=country,vulnerability_cat=vulnerability_options)
167
  # st.write('Selected country: ', country) # Debugging country
168
  if model_sel == "chatGPT":
169
  # res = pipe.run(query=input_text, documents=docs)
170
+ res = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": get_prompt(docs, input_text)}])
171
  output = res.choices[0].message.content
172
  references = get_refs(docs, output)
173
  # else:
 
263
 
264
 
265
  if selected_example == "-":
266
+ text = st.text_area('Enter your question in the text box below using natural language or select an example from above:')
267
  else:
268
+ text = st.text_area('Enter your question in the text box below using natural language or select an example from above:', value=selected_example)
269
 
270
 
271
  if st.button('Submit'):
272
+ run_query(text, country=country, model_sel=model_sel)
273
 
274
 
275