This is the error I keep getting using this code,
Error: litellm.APIError: APIError: OpenAIException - Connection error.
from crewai import Agent, Crew, Task, Process, LLM
from dotenv import load_dotenv
import os
# Load environment variables
load_dotenv()
# Azure OpenAI Configuration
AZURE_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT_RG")
API_VERSION = os.getenv("OPENAI_API_VERSION_RG")
DEPLOYMENT_NAME = os.getenv("AZURE_OPENAI_GPT4o_DEPLOYMENT")
API_KEY = os.getenv("AZURE_OPENAI_KEY_RG")
# Configure the LLM with all required Azure parameters
llm = LLM(
provider="azure",
model="gpt-4o", # Your model name - don't use azure/ prefix
api_key=API_KEY,
azure_endpoint=AZURE_ENDPOINT,
api_version=API_VERSION
)
# Define the Edge Case Identifier Agent
edge_case_identifier = Agent(
role="Edge Case Identifier",
goal="Identify Transaction ID's where the ML model's predictions are likely misclassified or uncertain. Do not analyse, only flag these cases.",
backstory="An AI agent trained to identify potential edge cases based on misclassifications in the model predictions without further analysis.",
llm=llm, # Use the configured LLM
verbose=True
)
# Define the Task for the Agent
edge_case_task = Task(
description="Flag transactions with prediction scores between 0.7143434968407539 and 0.864343496840754 as potential edge cases that require further review.",
agent=edge_case_identifier,
expected_output="A list of transaction IDs that fall within the specified score range and might be edge cases.",
)
# Create the Crew with the defined agent and task
crew = Crew(
agents=[edge_case_identifier],
tasks=[edge_case_task],
verbose=True
)