Browse Source

example add more type check (#24999)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
tags/1.8.1
Asuka Minato 2 months ago
parent
commit
a418c43d32
No account linked to committer's email address
2 changed files with 12 additions and 4 deletions
  1. 9
    1
      api/models/base.py
  2. 3
    3
      api/models/tools.py

+ 9
- 1
api/models/base.py View File

from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import DeclarativeBase, MappedAsDataclass


from models.engine import metadata from models.engine import metadata




class Base(DeclarativeBase): class Base(DeclarativeBase):
metadata = metadata metadata = metadata


class TypeBase(MappedAsDataclass, DeclarativeBase):
"""
This is for adding type, after all finished, rename to Base.
"""

metadata = metadata

+ 3
- 3
api/models/tools.py View File

from core.tools.entities.common_entities import I18nObject from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_bundle import ApiToolBundle from core.tools.entities.tool_bundle import ApiToolBundle
from core.tools.entities.tool_entities import ApiProviderSchemaType, WorkflowToolParameterConfiguration from core.tools.entities.tool_entities import ApiProviderSchemaType, WorkflowToolParameterConfiguration
from models.base import Base
from models.base import Base, TypeBase


from .engine import db from .engine import db
from .model import Account, App, Tenant from .model import Account, App, Tenant
return db.session.query(Tenant).where(Tenant.id == self.tenant_id).first() return db.session.query(Tenant).where(Tenant.id == self.tenant_id).first()




class ToolLabelBinding(Base):
class ToolLabelBinding(TypeBase):
""" """
The table stores the labels for tools. The table stores the labels for tools.
""" """
sa.UniqueConstraint("tool_id", "label_name", name="unique_tool_label_bind"), sa.UniqueConstraint("tool_id", "label_name", name="unique_tool_label_bind"),
) )


id: Mapped[str] = mapped_column(StringUUID, server_default=sa.text("uuid_generate_v4()"))
id: Mapped[str] = mapped_column(StringUUID, server_default=sa.text("uuid_generate_v4()"), init=False)
# tool id # tool id
tool_id: Mapped[str] = mapped_column(String(64), nullable=False) tool_id: Mapped[str] = mapped_column(String(64), nullable=False)
# tool type # tool type

Loading…
Cancel
Save