Spaces:
Sleeping
Sleeping
Update pages/Analysis.py
Browse files- pages/Analysis.py +25 -21
pages/Analysis.py
CHANGED
@@ -11,6 +11,7 @@ from utils.functions import (
|
|
11 |
)
|
12 |
import os
|
13 |
import re # Dodany import do obsługi wyrażeń regularnych
|
|
|
14 |
|
15 |
def show_analysis(language):
|
16 |
# Definiowanie tłumaczeń dla tej podstrony
|
@@ -61,7 +62,7 @@ def show_analysis(language):
|
|
61 |
'header': "📊 SMS Analysis",
|
62 |
'content': """Here is the interface for analyzing SMS messages. Enter the content of the message below to check if it is a potential fraud attempt.""",
|
63 |
'input_placeholder': "Enter SMS content...",
|
64 |
-
'analyze_button': "Analyze",
|
65 |
'result_positive': "Warning: The message may be a fraud!",
|
66 |
'result_negative': "The message appears to be safe.",
|
67 |
'report_button': "Report number as fraud",
|
@@ -85,7 +86,7 @@ def show_analysis(language):
|
|
85 |
|
86 |
with st.form("sms_form"):
|
87 |
message = st.text_area(
|
88 |
-
label=
|
89 |
placeholder=page_translations[language]['input_placeholder'],
|
90 |
height=150
|
91 |
)
|
@@ -225,21 +226,29 @@ def show_analysis(language):
|
|
225 |
st.error("API key missing. Set the SAMBANOVA_API_KEY environment variable in the app settings.")
|
226 |
else:
|
227 |
# Analiza za pomocą modelu AI
|
228 |
-
with st.spinner(
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
235 |
st.markdown(analysis_text)
|
236 |
-
st.subheader(
|
237 |
-
|
238 |
-
|
|
|
|
|
239 |
st.markdown(risk_text)
|
240 |
-
st.subheader(
|
241 |
-
|
242 |
-
|
|
|
|
|
243 |
st.markdown(recommendations_text)
|
244 |
|
245 |
# Aktualizacja statystyk na podstawie oceny ryzyka
|
@@ -268,12 +277,7 @@ def show_analysis(language):
|
|
268 |
|
269 |
# Zgłoszenie numeru jako oszustwo
|
270 |
if fraud_detected:
|
271 |
-
|
272 |
-
report_label = page_translations[language]['report_button']
|
273 |
-
elif language == 'German':
|
274 |
-
report_label = page_translations[language]['report_button']
|
275 |
-
else:
|
276 |
-
report_label = page_translations[language]['report_button']
|
277 |
|
278 |
if st.button(report_label):
|
279 |
success = add_fake_number(phone_number)
|
|
|
11 |
)
|
12 |
import os
|
13 |
import re # Dodany import do obsługi wyrażeń regularnych
|
14 |
+
import json
|
15 |
|
16 |
def show_analysis(language):
|
17 |
# Definiowanie tłumaczeń dla tej podstrony
|
|
|
62 |
'header': "📊 SMS Analysis",
|
63 |
'content': """Here is the interface for analyzing SMS messages. Enter the content of the message below to check if it is a potential fraud attempt.""",
|
64 |
'input_placeholder': "Enter SMS content...",
|
65 |
+
'analyze_button': "Analyze Message",
|
66 |
'result_positive': "Warning: The message may be a fraud!",
|
67 |
'result_negative': "The message appears to be safe.",
|
68 |
'report_button': "Report number as fraud",
|
|
|
86 |
|
87 |
with st.form("sms_form"):
|
88 |
message = st.text_area(
|
89 |
+
label=page_translations[language]['content'], # Non-empty label for accessibility
|
90 |
placeholder=page_translations[language]['input_placeholder'],
|
91 |
height=150
|
92 |
)
|
|
|
226 |
st.error("API key missing. Set the SAMBANOVA_API_KEY environment variable in the app settings.")
|
227 |
else:
|
228 |
# Analiza za pomocą modelu AI
|
229 |
+
with st.spinner(
|
230 |
+
"Analizuję wiadomość przy użyciu modelu AI..." if language == 'Polish' else
|
231 |
+
"Analysiere Nachricht mit AI-Modell..." if language == 'German' else
|
232 |
+
"Analyzing message using AI model..."
|
233 |
+
):
|
234 |
+
analysis_text, risk_text, recommendations_text = analyze_message(message, phone_number, additional_info, api_key, language)
|
235 |
+
st.subheader(
|
236 |
+
"📑 Analiza treści wiadomości:" if language == 'Polish' else
|
237 |
+
"📑 Nachrichteninhaltsanalyse:" if language == 'German' else
|
238 |
+
"📑 Message Content Analysis:"
|
239 |
+
)
|
240 |
st.markdown(analysis_text)
|
241 |
+
st.subheader(
|
242 |
+
"⚠️ Ocena ryzyka oszustwa:" if language == 'Polish' else
|
243 |
+
"⚠️ Bewertung des Betrugsrisikos:" if language == 'German' else
|
244 |
+
"⚠️ Fraud Risk Assessment:"
|
245 |
+
)
|
246 |
st.markdown(risk_text)
|
247 |
+
st.subheader(
|
248 |
+
"✅ Zalecenia dla użytkownika:" if language == 'Polish' else
|
249 |
+
"✅ Empfehlungen für den Benutzer:" if language == 'German' else
|
250 |
+
"✅ Recommendations for the User:"
|
251 |
+
)
|
252 |
st.markdown(recommendations_text)
|
253 |
|
254 |
# Aktualizacja statystyk na podstawie oceny ryzyka
|
|
|
277 |
|
278 |
# Zgłoszenie numeru jako oszustwo
|
279 |
if fraud_detected:
|
280 |
+
report_label = page_translations[language]['report_button']
|
|
|
|
|
|
|
|
|
|
|
281 |
|
282 |
if st.button(report_label):
|
283 |
success = add_fake_number(phone_number)
|