mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Class-based `Config` is deprecated in Pydantic v2 and removed in v3. Replace all 11 `class Config: from_attributes = True` blocks across the API schemas with `model_config = ConfigDict(from_attributes=True)`.
36 lines
699 B
Python
36 lines
699 B
Python
"""
|
|
Agents API Schemas
|
|
|
|
Request/response models for agent endpoints.
|
|
"""
|
|
|
|
from typing import Any, cast
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
from roboco.models import AgentRole, Team
|
|
|
|
|
|
class AgentResponse(BaseModel):
|
|
"""Response model for agent information."""
|
|
|
|
id: UUID
|
|
name: str
|
|
slug: str
|
|
role: AgentRole
|
|
team: Team | None
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
def agent_to_response(agent: Any) -> AgentResponse:
|
|
"""AgentTable → AgentResponse mapper."""
|
|
return AgentResponse(
|
|
id=cast("UUID", agent.id),
|
|
name=agent.name,
|
|
slug=agent.slug,
|
|
role=agent.role,
|
|
team=agent.team,
|
|
)
|