Update app.py
Browse files
app.py
CHANGED
@@ -161,17 +161,17 @@ def get_prompt(docs, query):
|
|
161 |
prompt = base_prompt+"; Context: "+context+"; Question: "+query+"; Answer:"
|
162 |
return(prompt)
|
163 |
|
164 |
-
def run_query(
|
165 |
# docs = get_docs(input_text, country)
|
166 |
-
docs = get_docs(
|
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, query=
|
171 |
output = res["results"][0]
|
172 |
references = get_refs(docs, output)
|
173 |
else:
|
174 |
-
res = client.text_generation(get_prompt_llama2(docs, query=
|
175 |
output = res
|
176 |
references = get_refs(docs, res)
|
177 |
st.write('Response')
|
@@ -263,13 +263,13 @@ else:
|
|
263 |
|
264 |
|
265 |
if selected_example == "-":
|
266 |
-
|
267 |
else:
|
268 |
-
|
269 |
|
270 |
|
271 |
if st.button('Submit'):
|
272 |
-
run_query(
|
273 |
|
274 |
|
275 |
|
|
|
161 |
prompt = base_prompt+"; Context: "+context+"; Question: "+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, query=input_query)}])
|
171 |
output = res["results"][0]
|
172 |
references = get_refs(docs, output)
|
173 |
else:
|
174 |
+
res = client.text_generation(get_prompt_llama2(docs, query=input_query), max_new_tokens=4000, temperature=0.01, model=model)
|
175 |
output = res
|
176 |
references = get_refs(docs, res)
|
177 |
st.write('Response')
|
|
|
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 |
|