diff --git a/ai/ai_simulations.py b/ai/ai_simulations.py index 1fd9bd3..6c024f7 100644 --- a/ai/ai_simulations.py +++ b/ai/ai_simulations.py @@ -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}") diff --git a/app.py b/app.py index 940d53a..8e0689f 100644 --- a/app.py +++ b/app.py @@ -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 @@ -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() diff --git a/backend/ai_chat.py b/backend/ai_chat.py index 169979b..af6112e 100644 --- a/backend/ai_chat.py +++ b/backend/ai_chat.py @@ -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 ""