feat: extend init_data to load and sync user_agent_catalog

- Add UserAgentCatalogSeed and UserAgentCatalogYaml Pydantic models
- Add load_user_agent_catalog function to load from YAML
- Add _upsert_user_agent_catalog helper for upsert logic
- Add initialize_user_agent_catalog function for initialization
- Refactor initialize_data to call initialize_llm_catalog and initialize_user_agent_catalog
- Fix UserAgentCatalog.llm_id type from str to uuid.UUID
This commit is contained in:
qzl
2026-03-02 15:58:13 +08:00
parent fb8f4fdeeb
commit 4afc67b7a8
2 changed files with 105 additions and 3 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
from __future__ import annotations
import uuid
from sqlalchemy import ForeignKey, String
from sqlalchemy.dialects.postgresql import JSONB, UUID
from sqlalchemy.orm import Mapped, mapped_column
@@ -14,7 +16,7 @@ class UserAgentCatalog(TimestampMixin, Base):
String(20),
primary_key=True,
)
llm_id: Mapped[str] = mapped_column(
llm_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("llms.id", ondelete="RESTRICT"),
nullable=False,