Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,13 @@ headers = {
|
|
9 |
"Content-Type": "application/json"
|
10 |
}
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def analyze_log(log_text):
|
13 |
if not log_text.strip():
|
14 |
return "Error: Please enter a log."
|
@@ -20,7 +27,7 @@ def analyze_log(log_text):
|
|
20 |
"content": "Analyze this satellite radio log and summarize in bullet points:\n- Issues (e.g., low signal, noise)\n- High-priority messages (e.g., emergencies)\n- Key details (e.g., coordinates, times)\nLog:\n" + log_text
|
21 |
}
|
22 |
],
|
23 |
-
"max_completion_tokens": 200,
|
24 |
"temperature": 0.5
|
25 |
}
|
26 |
try:
|
@@ -29,11 +36,17 @@ def analyze_log(log_text):
|
|
29 |
except Exception as e:
|
30 |
return f"Error: API call failed - {str(e)}"
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
interface.launch()
|
|
|
9 |
"Content-Type": "application/json"
|
10 |
}
|
11 |
|
12 |
+
# Sample log for button
|
13 |
+
SAMPLE_LOG = """
|
14 |
+
2025-04-12 10:01 UTC | 40.7N, 74.0W | Signal Strength: 85% | Message: Routine check, systems OK.
|
15 |
+
2025-04-12 10:02 UTC | 40.8N, 74.1W | Signal Strength: 60% | Message: Noise detected, check antenna.
|
16 |
+
2025-04-12 10:03 UTC | 40.9N, 74.2W | Signal Strength: 90% | Message: Emergency: Low battery alert.
|
17 |
+
"""
|
18 |
+
|
19 |
def analyze_log(log_text):
|
20 |
if not log_text.strip():
|
21 |
return "Error: Please enter a log."
|
|
|
27 |
"content": "Analyze this satellite radio log and summarize in bullet points:\n- Issues (e.g., low signal, noise)\n- High-priority messages (e.g., emergencies)\n- Key details (e.g., coordinates, times)\nLog:\n" + log_text
|
28 |
}
|
29 |
],
|
30 |
+
"max_completion_tokens": 200,
|
31 |
"temperature": 0.5
|
32 |
}
|
33 |
try:
|
|
|
36 |
except Exception as e:
|
37 |
return f"Error: API call failed - {str(e)}"
|
38 |
|
39 |
+
def load_sample_log():
|
40 |
+
return SAMPLE_LOG
|
41 |
+
|
42 |
+
with gr.Blocks() as interface:
|
43 |
+
gr.Markdown("# Satellite Signal Log Analyzer")
|
44 |
+
gr.Markdown("Enter a satellite radio log to detect issues and priorities using Llama 4 and Cerebras.")
|
45 |
+
log_input = gr.Textbox(lines=5, label="Satellite Radio Log")
|
46 |
+
sample_button = gr.Button("Load Sample Log")
|
47 |
+
output = gr.Textbox(label="Analysis Summary")
|
48 |
+
analyze_button = gr.Button("Analyze")
|
49 |
+
sample_button.click(fn=load_sample_log, outputs=log_input)
|
50 |
+
analyze_button.click(fn=analyze_log, inputs=log_input, outputs=output)
|
51 |
+
|
52 |
interface.launch()
|