From eee6f1fbf26e851cdabcb62038e73415b1e59121 Mon Sep 17 00:00:00 2001 From: jasonwcfan Date: Wed, 11 Sep 2024 16:05:59 -0400 Subject: [PATCH] rename id to finic_id and user_defined_id to id --- server/database/database.py | 4 ++-- server/models/models.py | 2 +- server/server/main.py | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/database/database.py b/server/database/database.py index 5aa9e607..d706ee65 100644 --- a/server/database/database.py +++ b/server/database/database.py @@ -78,13 +78,13 @@ async def upsert_agent(self, agent: Agent) -> Optional[Agent]: return None async def get_agent( - self, config: AppConfig, user_defined_id: str + self, config: AppConfig, id: str ) -> Optional[Agent]: response = ( self.supabase.table("agent") .select("*") .filter("app_id", "eq", config.app_id) - .filter("id", "eq", user_defined_id) + .filter("id", "eq", id) .execute() ) if len(response.data) > 0: diff --git a/server/models/models.py b/server/models/models.py index 243fdc60..9f0af318 100644 --- a/server/models/models.py +++ b/server/models/models.py @@ -33,8 +33,8 @@ class ExecutionStatus(str, Enum): class Agent(BaseModel): + finic_id: str id: str - user_defined_id: str app_id: str name: str status: AgentStatus diff --git a/server/server/main.py b/server/server/main.py index 073247c2..194c5680 100644 --- a/server/server/main.py +++ b/server/server/main.py @@ -105,7 +105,7 @@ async def deploy_agent( config: AppConfig = Depends(validate_token), ): try: - agent = await db.get_agent(config=config, user_defined_id=request.agent_id) + agent = await db.get_agent(config=config, id=request.agent_id) agent.status = AgentStatus.deploying await db.upsert_agent(agent) deployer = AgentDeployer(db=db, config=config) @@ -130,12 +130,12 @@ async def get_agent_upload_link( ): try: deployer = AgentDeployer(db=db, config=config) - agent = await db.get_agent(config=config, user_defined_id=request.agent_id) + agent = await db.get_agent(config=config, id=request.agent_id) if agent is None: agent = Agent( - id=str(uuid.uuid4()), + finic_id=str(uuid.uuid4()), app_id=config.app_id, - user_defined_id=request.agent_id, + id=request.agent_id, name=request.agent_name, num_retries=request.num_retries, status="deploying", @@ -155,7 +155,7 @@ async def run_agent( ): try: runner = AgentRunner(db=db, config=config) - agent = await db.get_agent(config=config, user_defined_id=request.agent_id) + agent = await db.get_agent(config=config, id=request.agent_id) if agent is None: raise HTTPException( status_code=404, detail=f"Agent {request.agent_id} not found" @@ -174,7 +174,7 @@ async def get_agent( config: AppConfig = Depends(validate_token), ): try: - agent = await db.get_agent(config=config, user_defined_id=agent_id) + agent = await db.get_agent(config=config, id=agent_id) return agent except Exception as e: print(e) @@ -200,7 +200,7 @@ async def get_execution( config: AppConfig = Depends(validate_token), ): try: - agent = await db.get_agent(config=config, user_defined_id=agent_id) + agent = await db.get_agent(config=config, id=agent_id) execution = await db.get_execution( config=config, agent_id=agent.id, execution_id=execution_id ) @@ -216,7 +216,7 @@ async def list_executions( config: AppConfig = Depends(validate_token), ): try: - agent = await db.get_agent(config=config, user_defined_id=agent_id) + agent = await db.get_agent(config=config, id=agent_id) executions = await db.list_executions(config=config, agent_id=agent.id) return executions except Exception as e: