Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

BUG-382: Fixing validation of team and agents #406

Merged
merged 8 commits into from
Feb 24, 2025
Prev Previous commit
Next Next commit
BUG-382: Revisited validation handling for also team agents
  • Loading branch information
kadirpekel committed Feb 18, 2025
commit 0b83e8689e633b15d1947544f8d81d1c5b8fc19c
2 changes: 1 addition & 1 deletion aixplain/modules/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -379,7 +379,7 @@ def update(self) -> None:
)
from aixplain.factories.agent_factory.utils import build_agent

self.validate(raise_exception=True)
self.validate()
url = urljoin(config.BACKEND_URL, f"sdk/agents/{self.id}")
headers = {"x-api-key": config.TEAM_API_KEY, "Content-Type": "application/json"}

18 changes: 17 additions & 1 deletion aixplain/modules/team_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -194,6 +194,8 @@ def run_async(
"""
from aixplain.factories.file_factory import FileFactory

self.validate(raise_exception=True)

assert data is not None or query is not None, "Either 'data' or 'query' must be provided."
if data is not None:
if isinstance(data, dict):
@@ -295,7 +297,7 @@ def to_dict(self) -> Dict:
"status": self.status.value,
}

def validate(self) -> None:
def _validate(self) -> None:
"""Validate the Team."""
from aixplain.factories.model_factory import ModelFactory

@@ -313,6 +315,20 @@ def validate(self) -> None:
for agent in self.agents:
agent.validate(raise_exception=True)

def validate(self, raise_exception: bool = False) -> bool:
try:
self._validate()
return True
except Exception as e:
if raise_exception:
raise e
else:
logging.warning(f"Team Agent Validation Error: {e}")
logging.warning(
"You won't be able to run the Team Agent until the issues are handled manually."
)
return False

def update(self) -> None:
"""Update the Team Agent."""
import warnings