pull/699/head
mike dupont 6 months ago
parent 2fbfcb8a82
commit a0c5b38e14

@ -34,30 +34,31 @@ kind = {}
def process_hunter_event(x): def process_hunter_event(x):
"Callback for trace events"
# <Event kind='call' # <Event kind='call'
# function='<module>' # function='<module>'
# module='ray.experimental.channel' # module='ray.experimental.channel'
# filename='/mnt/data1/nix/time/2024/05/31/swarms/api/.venv/lib/python3.10/site-packages/ray/experimental/channel/__init__.py'
# lineno=1> # lineno=1>
m = x.module mod = x.module
k = x.kind kind = x.kind
if k not in kind: if kind not in kind:
print("KIND", x) print("KIND", x)
kind[k] = 1 kind[kind] = 1
if "swarms" in m: if "swarms" in mod:
# hunter.CallPrinter(x) # hunter.CallPrinter(x)
print(x) print(x)
elif "uvicorn" in m: elif "uvicorn" in mod:
# hunter.CallPrinter(x) # hunter.CallPrinter(x)
# print(x) # print(x)
pass pass
if m not in seen: if mod not in seen:
print("MOD", m) print("MOD", mod)
seen[m] = 1 seen[mod] = 1
else: else:
seen[m] = seen[m]+11 seen[mod] = seen[mod]+11
hunter.trace( hunter.trace(
@ -258,8 +259,6 @@ class AgentStore:
api_key = secrets.token_urlsafe(API_KEY_LENGTH) api_key = secrets.token_urlsafe(API_KEY_LENGTH)
# Create the API key object # Create the API key object
key_name = "fixme"
user_id = "fixme"
key_object = APIKey( key_object = APIKey(
key=api_key, key=api_key,
name=key_name, name=key_name,
@ -302,8 +301,9 @@ class AgentStore:
self, config: AgentConfig, user_id: UUID self, config: AgentConfig, user_id: UUID
) -> UUID: ) -> UUID:
"""Create a new agent with the given configuration.""" """Create a new agent with the given configuration."""
states_time = f"{datetime.now().strftime('%Y%m%d_%H%M%S')}"
states_json = f"states/{config.agent_name}_{states_time}.json"
try: try:
agent = Agent( agent = Agent(
agent_name=config.agent_name, agent_name=config.agent_name,
system_prompt=config.system_prompt, system_prompt=config.system_prompt,
@ -339,6 +339,11 @@ class AgentStore:
"successful_completions": 0, "successful_completions": 0,
} }
# Add to user's agents list
if user_id not in self.user_agents:
self.user_agents[user_id] = []
self.user_agents[user_id].append(agent_id)
logger.info(f"Created agent with ID: {agent_id}") logger.info(f"Created agent with ID: {agent_id}")
logger.debug(f"Created agents:{self.agents.keys()}") logger.debug(f"Created agents:{self.agents.keys()}")
logger.info(f"agent store: {self}") logger.info(f"agent store: {self}")
@ -568,8 +573,9 @@ class AgentStore:
except Exception as e: except Exception as e:
metadata["error_count"] += 1 metadata["error_count"] += 1
metadata["status"] = AgentStatus.ERROR metadata["status"] = AgentStatus.ERROR
err= traceback.format_exc()
logger.error( logger.error(
f"Error in completion processing: {str(e)}\n{traceback.format_exc()}" f"Error in completion processing: {str(e)}\n{err}"
) )
raise HTTPException( raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,

Loading…
Cancel
Save