refactor(models): replace ConfigDict with SQLModelConfig for model configuration

This commit is contained in:
Abhimanyu Saharan
2026-02-15 02:16:17 +05:30
parent 395d215dac
commit 3bfefeda9f
4 changed files with 25 additions and 21 deletions

View File

@@ -7,7 +7,8 @@ from datetime import datetime
from typing import Any
from uuid import UUID
from pydantic import ConfigDict, Field, field_validator
from pydantic import Field, field_validator
from sqlmodel._compat import SQLModelConfig
from sqlmodel import SQLModel
from app.schemas.common import NonEmptyStr
@@ -42,7 +43,7 @@ def _normalize_identity_profile(
class AgentBase(SQLModel):
"""Common fields shared by agent create/read/update payloads."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "agent_profile",
"x-when-to-use": [
@@ -129,7 +130,7 @@ class AgentCreate(AgentBase):
class AgentUpdate(SQLModel):
"""Payload for patching an existing agent."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "agent_profile_update",
"x-when-to-use": [
@@ -214,7 +215,7 @@ class AgentUpdate(SQLModel):
class AgentRead(AgentBase):
"""Public agent representation returned by the API."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "agent_profile_lookup",
"x-when-to-use": [
@@ -251,7 +252,7 @@ class AgentRead(AgentBase):
class AgentHeartbeat(SQLModel):
"""Heartbeat status payload sent by agents."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "agent_health_signal",
"x-when-to-use": [
@@ -272,7 +273,7 @@ class AgentHeartbeat(SQLModel):
class AgentHeartbeatCreate(AgentHeartbeat):
"""Heartbeat payload used to create an agent lazily."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "agent_bootstrap",
"x-when-to-use": [
@@ -298,7 +299,7 @@ class AgentHeartbeatCreate(AgentHeartbeat):
class AgentNudge(SQLModel):
"""Nudge message payload for pinging an agent."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "agent_nudge",
"x-when-to-use": [

View File

@@ -2,14 +2,15 @@
from __future__ import annotations
from pydantic import ConfigDict, Field
from pydantic import Field
from sqlmodel import SQLModel
from sqlmodel._compat import SQLModelConfig
class LLMErrorResponse(SQLModel):
"""Standardized LLM-facing error payload used by API contracts."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"title": "LLMErrorResponse",
"x-llm-intent": "llm_error_handling",

View File

@@ -5,7 +5,8 @@ from __future__ import annotations
from typing import Literal
from uuid import UUID
from pydantic import ConfigDict, Field
from pydantic import Field
from sqlmodel._compat import SQLModelConfig
from sqlmodel import SQLModel
from app.schemas.common import NonEmptyStr
@@ -24,7 +25,7 @@ def _user_reply_tags() -> list[str]:
class GatewayLeadMessageRequest(SQLModel):
"""Request payload for sending a message to a board lead agent."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "lead_direct_message",
"x-when-to-use": [
@@ -71,7 +72,7 @@ class GatewayLeadMessageRequest(SQLModel):
class GatewayLeadMessageResponse(SQLModel):
"""Response payload for a lead-message dispatch attempt."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "lead_direct_message_result",
"x-when-to-use": [
@@ -104,7 +105,7 @@ class GatewayLeadMessageResponse(SQLModel):
class GatewayLeadBroadcastRequest(SQLModel):
"""Request payload for broadcasting a message to multiple board leads."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "lead_broadcast_message",
"x-when-to-use": [
@@ -154,7 +155,7 @@ class GatewayLeadBroadcastRequest(SQLModel):
class GatewayLeadBroadcastBoardResult(SQLModel):
"""Per-board result entry for a lead broadcast operation."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "lead_broadcast_status",
"x-when-to-use": [
@@ -184,7 +185,7 @@ class GatewayLeadBroadcastBoardResult(SQLModel):
class GatewayLeadBroadcastResponse(SQLModel):
"""Aggregate response for a lead broadcast operation."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "lead_broadcast_summary",
"x-when-to-use": [
@@ -208,7 +209,7 @@ class GatewayLeadBroadcastResponse(SQLModel):
class GatewayMainAskUserRequest(SQLModel):
"""Request payload for asking the end user via a main gateway agent."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "human_escalation_request",
"x-when-to-use": [
@@ -252,7 +253,7 @@ class GatewayMainAskUserRequest(SQLModel):
class GatewayMainAskUserResponse(SQLModel):
"""Response payload for user-question dispatch via gateway main agent."""
model_config = ConfigDict(
model_config = SQLModelConfig(
json_schema_extra={
"x-llm-intent": "human_escalation_result",
"x-when-to-use": [

View File

@@ -5,8 +5,9 @@ from __future__ import annotations
from datetime import datetime
from uuid import UUID
from pydantic import AnyHttpUrl, ConfigDict
from pydantic import AnyHttpUrl
from sqlmodel import Field, SQLModel
from sqlmodel._compat import SQLModelConfig
from app.schemas.common import NonEmptyStr
@@ -30,7 +31,7 @@ class SkillPackCreate(SQLModel):
branch: str = "main"
metadata_: dict[str, object] = Field(default_factory=dict, alias="metadata")
model_config = ConfigDict(validate_by_name=True)
model_config = SQLModelConfig(validate_by_name=True)
class MarketplaceSkillRead(SQLModel):
@@ -46,7 +47,7 @@ class MarketplaceSkillRead(SQLModel):
source_url: str
metadata_: dict[str, object] = Field(default_factory=dict, alias="metadata")
model_config = ConfigDict(validate_by_name=True)
model_config = SQLModelConfig(validate_by_name=True)
created_at: datetime
updated_at: datetime
@@ -63,7 +64,7 @@ class SkillPackRead(SQLModel):
branch: str
metadata_: dict[str, object] = Field(default_factory=dict, alias="metadata")
model_config = ConfigDict(validate_by_name=True)
model_config = SQLModelConfig(validate_by_name=True)
skill_count: int = 0
created_at: datetime