Spaces:
Runtime error
Runtime error
Jan Štihec
commited on
Commit
•
bd4f04b
1
Parent(s):
b1f3c8d
Invalid prediction check
Browse files
app.py
CHANGED
@@ -122,7 +122,7 @@ def run_ui():
|
|
122 |
st.stop()
|
123 |
|
124 |
elif submitted or st.session_state.valid_inputs_received:
|
125 |
-
pubmed_query = GPTHelper.gpt35_rephrase(fact) # Call gpt3.5 to rephrase fact as a PubMed query.
|
126 |
pubmed = load_pubmed_fetcher()
|
127 |
|
128 |
with st.spinner('Fetching articles...'):
|
@@ -166,13 +166,15 @@ def run_ui():
|
|
166 |
elif prediction == 'Undetermined':
|
167 |
predictions.append(prediction)
|
168 |
else:
|
|
|
|
|
169 |
logging.warning(f'Unexpected prediction: {prediction}')
|
170 |
|
171 |
percent_complete += step/100
|
172 |
fact_checking_bar.progress(round(percent_complete, 2), text=progress_text)
|
173 |
fact_checking_bar.empty()
|
174 |
df['Prediction'] = predictions
|
175 |
-
|
176 |
# Prepare DataFrame for plotly sunburst chart.
|
177 |
totals = df.groupby('Prediction').size().to_dict()
|
178 |
df['Total'] = df['Prediction'].map(totals)
|
|
|
122 |
st.stop()
|
123 |
|
124 |
elif submitted or st.session_state.valid_inputs_received:
|
125 |
+
pubmed_query = GPTHelper.gpt35_rephrase(fact) # Call gpt3.5 to rephrase the fact as a PubMed query.
|
126 |
pubmed = load_pubmed_fetcher()
|
127 |
|
128 |
with st.spinner('Fetching articles...'):
|
|
|
166 |
elif prediction == 'Undetermined':
|
167 |
predictions.append(prediction)
|
168 |
else:
|
169 |
+
# If GPT3.5 returns an invalid response. Has not happened during testing.
|
170 |
+
predictions.append('Invalid')
|
171 |
logging.warning(f'Unexpected prediction: {prediction}')
|
172 |
|
173 |
percent_complete += step/100
|
174 |
fact_checking_bar.progress(round(percent_complete, 2), text=progress_text)
|
175 |
fact_checking_bar.empty()
|
176 |
df['Prediction'] = predictions
|
177 |
+
df = df[df.Prediction != 'Invalid'] # Drop rows with invalid prediction.
|
178 |
# Prepare DataFrame for plotly sunburst chart.
|
179 |
totals = df.groupby('Prediction').size().to_dict()
|
180 |
df['Total'] = df['Prediction'].map(totals)
|