Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

convert to TypeBase (#27935)

Asuka Minato1bbb9d664451
diff --git a/api/models/provider.py b/api/models/provider.py
index e9365adb938..4de17a7fd5c 100644
--- a/api/models/provider.py
+++ b/api/models/provider.py
@@ -6,7 +6,7 @@ import sqlalchemy as sa
from sqlalchemy import DateTime, String, func, text
from sqlalchemy.orm import Mapped, mapped_column
-from .base import Base
+from .base import Base, TypeBase
from .engine import db
from .types import StringUUID
@@ -41,7 +41,7 @@ class ProviderQuotaType(StrEnum):
raise ValueError(f"No matching enum found for value '{value}'")
-class Provider(Base):
+class Provider(TypeBase):
"""
Provider model representing the API providers and their configurations.
"""
@@ -55,25 +55,27 @@ class Provider(Base):
),
)
- id: Mapped[str] = mapped_column(StringUUID, server_default=text("uuid_generate_v4()"))
+ id: Mapped[str] = mapped_column(StringUUID, primary_key=True, server_default=text("uuidv7()"), init=False)
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
provider_name: Mapped[str] = mapped_column(String(255), nullable=False)
provider_type: Mapped[str] = mapped_column(
- String(40), nullable=False, server_default=text("'custom'::character varying")
+ String(40), nullable=False, server_default=text("'custom'::character varying"), default="custom"
)
- is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("false"))
- last_used: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
- credential_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True)
+ is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("false"), default=False)
+ last_used: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, init=False)
+ credential_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True, default=None)
quota_type: Mapped[str | None] = mapped_column(
- String(40), nullable=True, server_default=text("''::character varying")
+ String(40), nullable=True, server_default=text("''::character varying"), default=""
)
- quota_limit: Mapped[int | None] = mapped_column(sa.BigInteger, nullable=True)
- quota_used: Mapped[int | None] = mapped_column(sa.BigInteger, default=0)
+ quota_limit: Mapped[int | None] = mapped_column(sa.BigInteger, nullable=True, default=None)
+ quota_used: Mapped[int] = mapped_column(sa.BigInteger, nullable=False, default=0)
- created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
+ created_at: Mapped[datetime] = mapped_column(
+ DateTime, nullable=False, server_default=func.current_timestamp(), init=False
+ )
updated_at: Mapped[datetime] = mapped_column(
- DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()
+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp(), init=False
)
def __repr__(self):