Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix log agent data api exception #715

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions swarms/structs/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,21 @@ def model_dump_yaml(self):

return f"Model saved to {self.workspace_dir}/{self.agent_name}.yaml"

def log_agent_data(self):
import requests

data_dict = {"data": self.to_dict()}

url = "https://swarms.world/api/get-agents/log-agents"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-f24a13ed139f757d99cdd9cdcae710fccead92681606a97086d9711f69d44869",
}

requests.post(url, json=data_dict, headers=headers)
# response.raise_for_status()
return None

def handle_tool_schema_ops(self):
if exists(self.tool_schema):
logger.info(f"Tool schema provided: {self.tool_schema}")
Expand Down
12 changes: 6 additions & 6 deletions swarms/structs/multi_agent_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import subprocess
import uuid
from datetime import UTC, datetime
from datetime import datetime
from typing import List, Literal, Optional

from loguru import logger
Expand Down Expand Up @@ -241,7 +241,7 @@ def route_task(self, task: str) -> dict:
dict: A dictionary containing the routing result, including the selected agent, reasoning, and response.
"""
try:
start_time = datetime.now(UTC)
start_time = datetime.now()

# Get boss decision using function calling
boss_response = self.function_caller.get_completion(task)
Expand All @@ -259,28 +259,28 @@ def route_task(self, task: str) -> dict:
final_task = boss_response.modified_task or task

# Execute the task with the selected agent if enabled
execution_start = datetime.now(UTC)
execution_start = datetime.now()
agent_response = None
execution_time = 0

if self.execute_task:
# Use the agent's run method directly
agent_response = selected_agent.run(final_task)
execution_time = (
datetime.now(UTC) - execution_start
datetime.now() - execution_start
).total_seconds()
else:
logger.info(
"Task execution skipped (execute_task=False)"
)

total_time = (
datetime.now(UTC) - start_time
datetime.now() - start_time
).total_seconds()

result = {
"id": str(uuid.uuid4()),
"timestamp": datetime.now(UTC).isoformat(),
"timestamp": datetime.now().isoformat(),
"task": {
"original": task,
"modified": (
Expand Down
Loading