Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ai/ai_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ def __init__(self):

def simulate_attack(self):
try:
if not self.scenarios:
raise IndexError("No scenarios available.")
scenario = random.choice(self.scenarios)
print(f"[SIMULATION] Executing simulated attack: {scenario}")
except IndexError as e:
print(f"Error during simulation: No scenarios available. {e}")
print(f"Error during simulation: {e}")
except Exception as e:
print(f"Error during simulation: {e}")

Expand Down
8 changes: 5 additions & 3 deletions analytics/behavioral_analysis.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

def detect_anomalies(user_data):
anomalies = []
for data in user_data:
if data["activity_level"] > 100:
anomalies.append(data["user_id"])
try:
if data["activity_level"] > 100:
anomalies.append(data["user_id"])
except KeyError:
print(f"Error: Missing 'activity_level' key in user data: {data}")
return anomalies

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
from typing import List, Tuple
import re
import os

import aiohttp
import panel as pn
Expand Down
8 changes: 7 additions & 1 deletion backend/pipeline_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def __init__(self):

def autogpt_task(self, task):
try:
openai.api_key = "YOUR_API_KEY"
api_key = "YOUR_API_KEY"
if not api_key:
raise ValueError("Missing API key")
openai.api_key = api_key
response = openai.Completion.create(
engine="text-davinci-003",
prompt=task,
Expand All @@ -28,6 +31,9 @@ def autogpt_task(self, task):
except openai.error.AuthenticationError as e:
logging.error(f"API key error during autogpt_task: {e}")
return "API key error"
except ValueError as e:
logging.error(f"ValueError during autogpt_task: {e}")
return "ValueError: Missing API key"
except Exception as e:
logging.error(f"Error during autogpt_task: {e}")
return ""
Expand Down
2 changes: 2 additions & 0 deletions core/email_server/EmailServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
SERVER_HOST = '0.0.0.0'
SERVER_PORT = 1234
saveMail_directory = os.getenv("SAVE_MAIL_DIRECTORY", "FlowSteering/ApplicationCode/EmailServer/EmailServerMailDatabase") # Change this to the directory where you want to save the emails inbox for each user
if not saveMail_directory:
raise ValueError("SAVE_MAIL_DIRECTORY environment variable is not set.")
message_queue = Queue()
default_image = 'FlowSteering/assets/PerturbatedImages/DjiPerturbClassForward.png'
# Server configuration
Expand Down
3 changes: 3 additions & 0 deletions core/end_user/EndUserClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
BaseEmails_directory = os.getenv("BASE_EMAILS_DIRECTORY")
default_image = os.getenv("DEFAULT_IMAGE", '')

if not BaseEmails_directory:
raise ValueError("BASE_EMAILS_DIRECTORY environment variable is not set.")


def receive_complete_data(client_socket): # this function is used to receive the complete data from the client, adjust the parameters as needed based on your network conditions
received_data = b""
Expand Down
5 changes: 4 additions & 1 deletion database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import logging
import os

Base = declarative_base()

Expand All @@ -13,7 +14,9 @@ class DocumentAnalysis(Base):
links = Column(Text, nullable=True)
error = Column(Text, nullable=True)

DATABASE_URL = "sqlite:///document_analysis.db"
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///document_analysis.db")
if not DATABASE_URL:
raise ValueError("DATABASE_URL environment variable is not set.")
engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base.metadata.create_all(bind=engine)
Expand Down
Loading