Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -525,12 +525,17 @@ def calculate_relevance_score(summary, model):
|
|
525 |
print(f"Raw relevance score response: {response}") # Debug print
|
526 |
|
527 |
try:
|
528 |
-
score
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
534 |
return 0.00
|
535 |
|
536 |
def ask_question(question, temperature, top_p, repetition_penalty, web_search, google_news_rss):
|
@@ -755,4 +760,4 @@ with gr.Blocks() as demo:
|
|
755 |
clear_button.click(clear_cache, inputs=[], outputs=clear_output)
|
756 |
|
757 |
if __name__ == "__main__":
|
758 |
-
demo.launch
|
|
|
525 |
print(f"Raw relevance score response: {response}") # Debug print
|
526 |
|
527 |
try:
|
528 |
+
# Extract the score from the response
|
529 |
+
score_match = re.search(r'Relevance Score:\s*(\d+\.\d+)', response)
|
530 |
+
if score_match:
|
531 |
+
score = float(score_match.group(1))
|
532 |
+
final_score = min(max(score, 0.00), 1.00) # Ensure the score is between 0.00 and 1.00
|
533 |
+
print(f"Processed relevance score: {final_score}") # Debug print
|
534 |
+
return final_score
|
535 |
+
else:
|
536 |
+
raise ValueError("No relevance score found in the response")
|
537 |
+
except ValueError as e:
|
538 |
+
print(f"Error parsing relevance score: {e}")
|
539 |
return 0.00
|
540 |
|
541 |
def ask_question(question, temperature, top_p, repetition_penalty, web_search, google_news_rss):
|
|
|
760 |
clear_button.click(clear_cache, inputs=[], outputs=clear_output)
|
761 |
|
762 |
if __name__ == "__main__":
|
763 |
+
demo.launch()
|