workbykait commited on
Commit
c57ef4b
·
verified ·
1 Parent(s): aeccdc3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -4,6 +4,7 @@ import os
4
  import random
5
  from datetime import datetime, timedelta
6
  import plotly.express as px
 
7
 
8
  api_key = os.getenv("CEREBRAS_API_KEY")
9
  url = "https://api.cerebras.ai/v1/chat/completions"
@@ -69,10 +70,10 @@ def analyze_log(log_text):
69
  elif line.strip():
70
  html += f"<li>{line.strip()}</li>"
71
  html += "</ul></div>"
72
- # Extract signal strengths for plot
73
- signals = [int(s.split("%")[0]) for s in log_text.split("\n") if "Signal Strength" in s]
74
- times = [line.split(" | ")[0] for line in log_text.split("\n") if "Signal Strength" in s]
75
- fig = px.line(x=times, y=signals, labels={"x": "Time", "y": "Signal Strength (%)"}, title="Signal Strength Trend")
76
  return summary, html, fig
77
  except Exception as e:
78
  return f"Error: API call failed - {str(e)}", None, None
@@ -110,7 +111,7 @@ def compare_logs():
110
  "content": "Compare these two satellite radio logs and summarize trends in bullet points (e.g., signal strength changes, frequency issues, new emergencies):\n" + compare_text
111
  }
112
  ],
113
- "max_completion_tokens": 300, # Increased
114
  "temperature": 0.5
115
  }
116
  try:
@@ -131,7 +132,7 @@ def load_sample_log():
131
  def clear_log():
132
  return ""
133
 
134
- with gr.Blocks(theme="huggingface/dark") as interface:
135
  gr.Markdown("# Satellite Signal Log Analyzer")
136
  gr.Markdown("Analyze satellite radio logs for issues, alerts, trends, and signal visuals using Llama 4 and Cerebras.")
137
  log_input = gr.Textbox(lines=5, label="Satellite Radio Log")
 
4
  import random
5
  from datetime import datetime, timedelta
6
  import plotly.express as px
7
+ import re
8
 
9
  api_key = os.getenv("CEREBRAS_API_KEY")
10
  url = "https://api.cerebras.ai/v1/chat/completions"
 
70
  elif line.strip():
71
  html += f"<li>{line.strip()}</li>"
72
  html += "</ul></div>"
73
+ # Extract signals with regex
74
+ signals = [int(m.group(1)) for m in re.finditer(r"Signal Strength: (\d+)%", log_text)]
75
+ times = [line.split(" | ")[0][-8:] for line in log_text.split("\n") if "Signal Strength" in s]
76
+ fig = px.line(x=times, y=signals, labels={"x": "Time (UTC)", "y": "Signal Strength (%)"}, title="Signal Strength Trend") if signals and times else None
77
  return summary, html, fig
78
  except Exception as e:
79
  return f"Error: API call failed - {str(e)}", None, None
 
111
  "content": "Compare these two satellite radio logs and summarize trends in bullet points (e.g., signal strength changes, frequency issues, new emergencies):\n" + compare_text
112
  }
113
  ],
114
+ "max_completion_tokens": 400,
115
  "temperature": 0.5
116
  }
117
  try:
 
132
  def clear_log():
133
  return ""
134
 
135
+ with gr.Blocks(theme="soft") as interface:
136
  gr.Markdown("# Satellite Signal Log Analyzer")
137
  gr.Markdown("Analyze satellite radio logs for issues, alerts, trends, and signal visuals using Llama 4 and Cerebras.")
138
  log_input = gr.Textbox(lines=5, label="Satellite Radio Log")