Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -77,11 +77,11 @@ def detect_context(input_text, threshold=0.03):
|
|
77 |
label_probabilities = list(zip(labels, probabilities))
|
78 |
|
79 |
# Filter contexts with confidence >= threshold
|
80 |
-
high_confidence_contexts = [label in label_probabilities if score >= threshold]
|
81 |
|
82 |
# If no contexts meet the threshold, default to "general"
|
83 |
if not high_confidence_contexts:
|
84 |
-
high_confidence_contexts = [("general")]
|
85 |
|
86 |
return high_confidence_contexts
|
87 |
|
@@ -109,9 +109,7 @@ def process_request(input_text):
|
|
109 |
def gradio_interface(input_text):
|
110 |
translation, contexts = process_request(input_text)
|
111 |
# Format the output
|
112 |
-
output = f"Translation: {translation}\n
|
113 |
-
for context in contexts:
|
114 |
-
output += f"- {context}\n"
|
115 |
return output.strip()
|
116 |
|
117 |
# Create the Gradio interface
|
|
|
77 |
label_probabilities = list(zip(labels, probabilities))
|
78 |
|
79 |
# Filter contexts with confidence >= threshold
|
80 |
+
high_confidence_contexts = [[(label, score) for label, scores in label_probabilities if score >= threshold]
|
81 |
|
82 |
# If no contexts meet the threshold, default to "general"
|
83 |
if not high_confidence_contexts:
|
84 |
+
high_confidence_contexts = [("general", 1.0)]
|
85 |
|
86 |
return high_confidence_contexts
|
87 |
|
|
|
109 |
def gradio_interface(input_text):
|
110 |
translation, contexts = process_request(input_text)
|
111 |
# Format the output
|
112 |
+
output = f"Translation: {translation}\n"
|
|
|
|
|
113 |
return output.strip()
|
114 |
|
115 |
# Create the Gradio interface
|