Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -200,12 +200,14 @@ health of the system in one word - good or critical in the same line.
|
|
| 200 |
return self.results
|
| 201 |
|
| 202 |
|
| 203 |
-
def main_LogAnalyzer(queries):
|
| 204 |
-
log_file_path = 'sample.log'
|
| 205 |
csv_file_path = 'sample_log.csv'
|
| 206 |
qdrant_data_dir = 'qdrant_data'
|
| 207 |
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
# Process log to CSV
|
| 211 |
log_analyzer.process_log_to_csv()
|
|
@@ -239,7 +241,7 @@ def render_markdown(md_text):
|
|
| 239 |
# Display the HTML
|
| 240 |
display(HTML(html))
|
| 241 |
|
| 242 |
-
def agent_LA(
|
| 243 |
# Perform a query
|
| 244 |
queries = [
|
| 245 |
"What are the most common errors in the logs?",
|
|
@@ -250,7 +252,7 @@ def agent_LA(query):
|
|
| 250 |
"Is the Health of the system critical"
|
| 251 |
]
|
| 252 |
|
| 253 |
-
results = main_LogAnalyzer(queries)
|
| 254 |
# Format the results dictionary into a markdown string
|
| 255 |
markdown_out = ""
|
| 256 |
for query, answer in results.items():
|
|
@@ -263,16 +265,17 @@ def agent_LA(query):
|
|
| 263 |
if HP.health == "Critical":
|
| 264 |
health_result = "SYSTEM IN HIGH ALERT STATE"
|
| 265 |
else:
|
| 266 |
-
|
| 267 |
|
| 268 |
-
final_result = markdown_out + "\n ## HEALTH
|
| 269 |
return final_result
|
| 270 |
|
| 271 |
|
| 272 |
-
def greet(query):
|
| 273 |
-
return agent_LA(query)
|
| 274 |
-
|
| 275 |
markdown_output = gr.Markdown()
|
| 276 |
-
|
| 277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
demo.launch(share=True)
|
|
|
|
| 200 |
return self.results
|
| 201 |
|
| 202 |
|
| 203 |
+
def main_LogAnalyzer(log_file_path, queries):
|
|
|
|
| 204 |
csv_file_path = 'sample_log.csv'
|
| 205 |
qdrant_data_dir = 'qdrant_data'
|
| 206 |
|
| 207 |
+
with open(log_file_path.name, 'r') as f_in, open(csv_file_path, 'w') as f_out:
|
| 208 |
+
f_out.write(f_in.read())
|
| 209 |
+
|
| 210 |
+
log_analyzer = LogAnalyzer(log_file_path.name, csv_file_path, qdrant_data_dir)
|
| 211 |
|
| 212 |
# Process log to CSV
|
| 213 |
log_analyzer.process_log_to_csv()
|
|
|
|
| 241 |
# Display the HTML
|
| 242 |
display(HTML(html))
|
| 243 |
|
| 244 |
+
def agent_LA(log_file):
|
| 245 |
# Perform a query
|
| 246 |
queries = [
|
| 247 |
"What are the most common errors in the logs?",
|
|
|
|
| 252 |
"Is the Health of the system critical"
|
| 253 |
]
|
| 254 |
|
| 255 |
+
results = main_LogAnalyzer(log_file, queries)
|
| 256 |
# Format the results dictionary into a markdown string
|
| 257 |
markdown_out = ""
|
| 258 |
for query, answer in results.items():
|
|
|
|
| 265 |
if HP.health == "Critical":
|
| 266 |
health_result = "SYSTEM IN HIGH ALERT STATE"
|
| 267 |
else:
|
| 268 |
+
health_result = "SYSTEM IN GOOD HEALTH"
|
| 269 |
|
| 270 |
+
final_result = markdown_out + "\n ## HEALTH INSPECTOR \n\n " + health_result
|
| 271 |
return final_result
|
| 272 |
|
| 273 |
|
|
|
|
|
|
|
|
|
|
| 274 |
markdown_output = gr.Markdown()
|
| 275 |
+
demo = gr.Interface(
|
| 276 |
+
fn=agent_LA,
|
| 277 |
+
inputs=gr.File(label="Upload Log File", file_types=[".log", ".txt"]),
|
| 278 |
+
outputs=markdown_output,
|
| 279 |
+
title="Log Analyzer Agent"
|
| 280 |
+
)
|
| 281 |
demo.launch(share=True)
|