|
|
|
@ -1,18 +1,27 @@
|
|
|
|
|
import os
|
|
|
|
|
import secrets
|
|
|
|
|
import sys
|
|
|
|
|
# import sys
|
|
|
|
|
import traceback
|
|
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
from enum import Enum
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
# from pathlib import Path
|
|
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
from uuid import UUID, uuid4
|
|
|
|
|
|
|
|
|
|
import hunter
|
|
|
|
|
import uvicorn
|
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
from fastapi import BackgroundTasks, FastAPI, HTTPException, Query, status
|
|
|
|
|
from fastapi import (
|
|
|
|
|
BackgroundTasks,
|
|
|
|
|
Depends,
|
|
|
|
|
FastAPI,
|
|
|
|
|
Header,
|
|
|
|
|
HTTPException,
|
|
|
|
|
Query,
|
|
|
|
|
Request,
|
|
|
|
|
status,
|
|
|
|
|
)
|
|
|
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
from loguru import logger
|
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
@ -22,7 +31,9 @@ from swarms.structs.agent import Agent
|
|
|
|
|
|
|
|
|
|
seen = {}
|
|
|
|
|
kind = {}
|
|
|
|
|
def foo(x):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_hunter_event(x):
|
|
|
|
|
# <Event kind='call'
|
|
|
|
|
# function='<module>'
|
|
|
|
|
# module='ray.experimental.channel'
|
|
|
|
@ -42,17 +53,16 @@ def foo(x):
|
|
|
|
|
# print(x)
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if m not in seen:
|
|
|
|
|
|
|
|
|
|
print("MOD", m)
|
|
|
|
|
seen[m] = 1
|
|
|
|
|
else:
|
|
|
|
|
seen[m] = seen[m]+11
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hunter.trace(
|
|
|
|
|
stdlib=False,
|
|
|
|
|
action=foo
|
|
|
|
|
action=process_hunter_event
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# print("starting")
|
|
|
|
@ -82,10 +92,12 @@ class APIKey(BaseModel):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class APIKeyCreate(BaseModel):
|
|
|
|
|
"Fixme"
|
|
|
|
|
name: str # A friendly name for the API key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class User(BaseModel):
|
|
|
|
|
"User "
|
|
|
|
|
id: UUID
|
|
|
|
|
username: str
|
|
|
|
|
is_active: bool = True
|
|
|
|
@ -246,6 +258,8 @@ class AgentStore:
|
|
|
|
|
api_key = secrets.token_urlsafe(API_KEY_LENGTH)
|
|
|
|
|
|
|
|
|
|
# Create the API key object
|
|
|
|
|
key_name = "fixme"
|
|
|
|
|
user_id = "fixme"
|
|
|
|
|
key_object = APIKey(
|
|
|
|
|
key=api_key,
|
|
|
|
|
name=key_name,
|
|
|
|
@ -330,11 +344,11 @@ class AgentStore:
|
|
|
|
|
logger.info(f"agent store: {self}")
|
|
|
|
|
return agent_id
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logger.error(f"Error creating agent: {str(e)}")
|
|
|
|
|
except Exception as exp:
|
|
|
|
|
logger.error(f"Error creating agent: {str(exp)}")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
|
|
|
detail=f"Failed to create agent: {str(e)}",
|
|
|
|
|
detail=f"Failed to create agent: {str(exp)}",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
async def get_agent(self, agent_id: UUID) -> Agent:
|
|
|
|
|