Skip to content
Merged
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
15 changes: 7 additions & 8 deletions aixplain/modules/team_agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def __init__(
self.output_format = output_format
self.expected_output = expected_output

def generate_session_id(self, history: list = None) -> str:
timestamp = datetime.now().strftime('%Y%m%d%H%M%S')
def generate_session_id(self, history: list = None) -> str:
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
session_id = f"{self.id}_{timestamp}"

if not history:
Expand All @@ -136,7 +136,7 @@ def generate_session_id(self, history: list = None) -> str:

payload = {
"id": self.id,
"query": "/",
"query": "/",
"sessionId": session_id,
"history": history,
"executionParams": {
Expand All @@ -145,7 +145,7 @@ def generate_session_id(self, history: list = None) -> str:
"outputFormat": OutputFormat.TEXT.value,
"expectedOutput": None,
},
"allowHistoryAndSessionId": True
"allowHistoryAndSessionId": True,
}

r = _request_with_retry("post", self.url, headers=headers, data=json.dumps(payload))
Expand All @@ -163,7 +163,6 @@ def generate_session_id(self, history: list = None) -> str:
logging.error(f"Failed to initialize team session {session_id}: {e}")
return session_id


def run(
self,
data: Optional[Union[Dict, Text]] = None,
Expand Down Expand Up @@ -291,10 +290,10 @@ def run_async(
if session_id is not None:
if not session_id.startswith(f"{self.id}_"):
raise ValueError(f"Session ID '{session_id}' does not belong to this Agent.")

if history:
validate_history(history)

from aixplain.factories.file_factory import FileFactory

if not self.is_valid:
Expand Down Expand Up @@ -620,7 +619,7 @@ def update(self) -> None:
error_msg = f"Team Agent Update Error (HTTP {r.status_code}): {resp}"
raise Exception(error_msg)

def save(self) -> None:
def save(self) -> None:
"""Save the Agent."""
self.update()

Expand Down