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
2 changes: 0 additions & 2 deletions ai/ai_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def simulate_attack(self):
return

try:
if not self.scenarios:
raise IndexError("No scenarios available.")
scenario = random.choice(self.scenarios)
print(f"[SIMULATION] Executing simulated attack: {scenario}")

Expand Down
29 changes: 14 additions & 15 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,19 @@


async def random_url(_):
retries = 3
for _ in range(retries):
try:
pet = random.choice(["cat", "dog"])
api_url = f"https://api.the{pet}api.com/v1/images/search"
async with aiohttp.ClientSession() as session:
async with session.get(api_url) as resp:
resp.raise_for_status()
return (await resp.json())[0]["url"]
except aiohttp.ClientError as e:
logging.error(f"API request failed: {e}")
except Exception as e:
logging.error(f"Unexpected error: {e}")
return None
try:
pet = random.choice(["cat", "dog"])
api_url = f"https://api.the{pet}api.com/v1/images/search"
async with aiohttp.ClientSession() as session:
async with session.get(api_url) as resp:
resp.raise_for_status()
return (await resp.json())[0]["url"]
except aiohttp.ClientError as e:
logging.error(f"API request failed: {e}")
return None
except Exception as e:
logging.error(f"Unexpected error: {e}")
return None


@pn.cache
Expand Down Expand Up @@ -270,7 +269,7 @@ async def process_inputs(class_names: List[str], image_url: str):
macos_control = MacOSControl()
linux_control = LinuxControl()
android_control = AndroidControl()
ios_control = iOSControl()
ios_control = IOSControl()
advanced_device_control = AdvancedDeviceControl()
code_parser = CodeParser("sample_code")
pipeline_manager = PipelineManager()
Expand Down
3 changes: 3 additions & 0 deletions backend/ai_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def openai_chat(self, prompt):
openai.api_key = self.openai_key
response = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=100)
return response.choices[0].text.strip()
except openai.error.AuthenticationError as e:
logging.error(f"Authentication error during OpenAI chat: {e}")
return "Authentication error"
except Exception as e:
logging.error(f"Error during OpenAI chat: {e}")
return ""
Expand Down
Loading