feat(shipping-notice): 添加订单抽取功能,支持异步运行和管理,优化相关数据模型和处理逻辑
This commit is contained in:
1 parent
34d489a2d1
commit
ce26d6d0c4
144 files changed
+12241
-4233
No files matched your search
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
backend/app/models/agent_runtime_binding.py
|
||||
|
||||
用途:定义用户入口 Agent 到内部运行能力 Provider 的显式绑定。
|
||||
依赖:agents 表。
|
||||
逻辑:业务代码只按 owner_agent_id + capability_code 解析 Provider;Dify App ID、Key 和 URL 继续由 Provider Agent 保存。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Optional
|
||||
|
||||
from sqlalchemy import Boolean, ForeignKey, JSON, String, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class AgentRuntimeBinding(Base):
|
||||
"""一个 Agent 的命名运行能力绑定;同一能力只允许一个当前 Provider。"""
|
||||
|
||||
__tablename__ = 'agent_runtime_bindings'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('owner_agent_id', 'capability_code', name='uq_agent_runtime_binding_capability'),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
owner_agent_id: Mapped[int] = mapped_column(
|
||||
ForeignKey('agents.id', ondelete='CASCADE'), nullable=False, index=True,
|
||||
)
|
||||
capability_code: Mapped[str] = mapped_column(String(100), nullable=False, index=True)
|
||||
provider_agent_id: Mapped[int] = mapped_column(
|
||||
ForeignKey('agents.id'), nullable=False, index=True,
|
||||
)
|
||||
enabled: Mapped[bool] = mapped_column(Boolean, default=True, server_default='1', nullable=False)
|
||||
config_json: Mapped[Optional[dict[str, Any]]] = mapped_column(JSON, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
||||
|
||||
owner_agent: Mapped['Agent'] = relationship('Agent', foreign_keys=[owner_agent_id])
|
||||
provider_agent: Mapped['Agent'] = relationship('Agent', foreign_keys=[provider_agent_id])
|
||||
Reference in new issue
Block a user