mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-21 07:26:50 +00:00
3b4622a26f
- Replace custom UTFJSON type with standard sqlalchemy.JSON in all ORM models. Add json_serializer=json.dumps(ensure_ascii=False) to all create_async_engine calls so non-ASCII text (Chinese etc.) is stored as-is in both SQLite and Postgres. - Change ORM datetime defaults from datetime.now(UTC) to datetime.now(), remove UTC imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""ORM model for run events."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import JSON, DateTime, Index, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from deerflow.persistence.base import Base
|
|
|
|
|
|
class RunEventRow(Base):
|
|
__tablename__ = "run_events"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
thread_id: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
run_id: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
event_type: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
category: Mapped[str] = mapped_column(String(16), nullable=False)
|
|
# "message" | "trace" | "lifecycle"
|
|
content: Mapped[str] = mapped_column(Text, default="")
|
|
event_metadata: Mapped[dict] = mapped_column(JSON, default=dict)
|
|
seq: Mapped[int] = mapped_column(nullable=False)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now())
|
|
|
|
__table_args__ = (
|
|
Index("ix_events_thread_cat_seq", "thread_id", "category", "seq"),
|
|
Index("ix_events_run", "thread_id", "run_id", "seq"),
|
|
)
|