Offloaded data detection from the LLM and hardcoded it

This commit is contained in:
2025-08-24 13:30:21 -05:00
parent 6f7e99639c
commit d102dc30f4
2 changed files with 13 additions and 5 deletions

View File

@@ -284,6 +284,7 @@ def build_llm_prompt(anomalies):
def generate_llm_report(anomalies):
"""Generates a report from a list of anomalies using the local LLM."""
logger.info("Generating LLM report...")
if not anomalies:
return {"severity": "none", "reason": ""}
@@ -322,7 +323,13 @@ def generate_llm_report(anomalies):
def send_discord_alert(llm_response, combined_data):
"""Sends an alert to Discord."""
reason = llm_response.get('reason', 'No reason provided.')
message = f"**High Severity Alert:**\n> {reason}\n\n**Relevant Data:**\n```json\n{json.dumps(combined_data, indent=2)}\n```"
message = f"""**High Severity Alert:**
> {reason}
**Relevant Data:**
```json
{json.dumps(combined_data, indent=2)}
```"""
webhook = DiscordWebhook(url=config.DISCORD_WEBHOOK_URL, content=message)
try:
response = webhook.execute()
@@ -430,6 +437,7 @@ def run_monitoring_cycle(nmap_scan_counter):
anomalies = analyze_data_locally(combined_data, baselines, known_issues, port_applications)
if anomalies:
logger.info(f"Detected {len(anomalies)} anomalies: {anomalies}")
llm_response = generate_llm_report(anomalies)
if llm_response and llm_response.get('severity') != "none":
daily_events.append(llm_response.get('reason'))
@@ -452,4 +460,4 @@ def main():
time.sleep(300) # Run every 5 minutes
if __name__ == "__main__":
main()
main()