from ..models import Agent class AgentService: @staticmethod def create_agent(workspace_id, data): agent = Agent( workspace_id=workspace_id, name=data["name"], description=data.get("description"), system_prompt=data.get("system_prompt"), model_id=data.get("model_id"), temperature=data.get("temperature", 0.70), max_tokens=data.get("max_tokens", 2000), ) agent.save() return agent @staticmethod def update_agent(agent, data): if "name" in data: agent.name = data["name"] if "description" in data: agent.description = data["description"] if "system_prompt" in data: agent.system_prompt = data["system_prompt"] if "model_id" in data: agent.model_id = data["model_id"] if "temperature" in data: agent.temperature = data["temperature"] if "max_tokens" in data: agent.max_tokens = data["max_tokens"] if "is_active" in data: agent.is_active = data["is_active"] agent.save() return agent @staticmethod def delete_agent(agent): agent.delete()