# Copyright 2026 zhaoxi826 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from typing import Union from fastapi import APIRouter, Request, Depends from pydantic import BaseModel from pretor.utils.access import Accessor, TokenData agent_router = APIRouter(prefix="/api/v1/agent", tags=["agent"]) class AgentRegister(BaseModel): provider_title: str model_id: str individual_name: str class AgentLocalRegister(BaseModel): path: str individual_name: str @agent_router.post("") async def load_agent(agent_register: Union[AgentRegister, AgentLocalRegister], request: Request, _: TokenData = Depends(Accessor.get_current_user)): global_state_machine = request.app.state.global_state_machine if isinstance(agent_register, AgentLocalRegister): pass elif isinstance(agent_register, AgentRegister): match agent_register.individual_title: case "supervisory_node": node = request.app.state.supervisory_node node.create_agent.remote(global_state_machine,agent_register.provider_title,agent_register.model_id) case "consciousness_node": node = request.app.state.consciousness_node node.create_agent.remote(global_state_machine,agent_register.provider_title,agent_register.model_id) case "control_node": node = request.app.state.control_node node.create_agent.remote(global_state_machine,agent_register.provider_title,agent_register.model_id) case _: pass return {"message": "εˆ›ε»ΊζˆεŠŸ"}