Spaces:
Sleeping
Sleeping
Commit
·
c4d5b35
1
Parent(s):
d902698
Update app.py
Browse files
app.py
CHANGED
@@ -120,20 +120,8 @@ def generate_answer(question,openAI_key):
|
|
120 |
if not recommender.fitted:
|
121 |
st.error('The recommender is not fitted yet.')
|
122 |
return
|
123 |
-
prompt = ""
|
124 |
-
prompt += 'search results:\n\n'
|
125 |
-
for c in topn_chunks:
|
126 |
-
prompt += c + '\n\n'
|
127 |
-
|
128 |
-
prompt += "Instructions: Compose a comprehensive reply to the query using the search results given. "\
|
129 |
-
"Cite each reference using [Page Number] notation (every result has this number at the beginning). "\
|
130 |
-
"Citation should be done at the end of each sentence. If the search results mention multiple subjects "\
|
131 |
-
"with the same name, create separate answers for each. Only include information found in the results and "\
|
132 |
-
"don't add any additional information. Make sure the answer is correct, and don't output false content. "\
|
133 |
-
"If the text does not relate to the query, simply state 'Found Nothing'. Ignore outlier "\
|
134 |
-
"search results that have nothing to do with the question. Only answer what is asked. The "\
|
135 |
-
"answer should be short and concise. \n\nQuery: {question}\nAnswer: "
|
136 |
|
|
|
137 |
prompt += f"Query: {question}\nAnswer: "
|
138 |
answer = generate_text(openAI_key, prompt,"text-davinci-003")
|
139 |
|
@@ -160,6 +148,15 @@ row_count = st.session_state.get("row_count", 1)
|
|
160 |
num_concurrent_calls = st.sidebar.number_input("Concurrent Calls:", min_value=1, max_value=2000, value=10, step=1)
|
161 |
generate_all = st.sidebar.button("Generate All")
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
if add_row:
|
164 |
row_count += 1
|
165 |
st.session_state.row_count = row_count
|
|
|
120 |
if not recommender.fitted:
|
121 |
st.error('The recommender is not fitted yet.')
|
122 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
+
# Replace the hard-coded string with the variable prompt
|
125 |
prompt += f"Query: {question}\nAnswer: "
|
126 |
answer = generate_text(openAI_key, prompt,"text-davinci-003")
|
127 |
|
|
|
148 |
num_concurrent_calls = st.sidebar.number_input("Concurrent Calls:", min_value=1, max_value=2000, value=10, step=1)
|
149 |
generate_all = st.sidebar.button("Generate All")
|
150 |
|
151 |
+
prompt = st.sidebar.text_area('Prompt', value="""Instructions: Compose a comprehensive reply to the query using the search results given.
|
152 |
+
Cite each reference using [Page Number] notation (every result has this number at the beginning).
|
153 |
+
Citation should be done at the end of each sentence. If the search results mention multiple subjects
|
154 |
+
with the same name, create separate answers for each. Only include information found in the results and
|
155 |
+
don't add any additional information. Make sure the answer is correct, and don't output false content.
|
156 |
+
If the text does not relate to the query, simply state 'Found Nothing'. Ignore outlier
|
157 |
+
search results that have nothing to do with the question. Only answer what is asked. The
|
158 |
+
answer should be short and concise. \n\nQuery: {question}\nAnswer: """)
|
159 |
+
|
160 |
if add_row:
|
161 |
row_count += 1
|
162 |
st.session_state.row_count = row_count
|