Skip to content

Commit

Permalink
feat: annotation table persistence
Browse files Browse the repository at this point in the history
Update src/phoenix/db/models.py

small update
  • Loading branch information
mikeldking committed Apr 5, 2024
1 parent 30b2ab0 commit 5d22906
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/phoenix/db/migrations/versions/cf03bd6bae1d_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def upgrade() -> None:
sa.Column("cumulative_llm_token_count_prompt", sa.Integer, nullable=False),
sa.Column("cumulative_llm_token_count_completion", sa.Integer, nullable=False),
)

op.bulk_insert(
projects_table,
[
Expand Down
19 changes: 19 additions & 0 deletions src/phoenix/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,22 @@ async def init_models(engine: AsyncEngine) -> None:
description="default project",
)
)


class SpanAnnotation(Base):
__tablename__ = "span_annotations"
id: Mapped[int] = mapped_column(primary_key=True)
span_rowid: Mapped[int] = mapped_column(ForeignKey("spans.id"), required=True)
name: Mapped[str] = mapped_column(required=True)
label: Mapped[str] = mapped_column()
score: Mapped[float] = mapped_column()
explanation: Mapped[str] = mapped_column()
meta: Mapped[Dict[str, Any]] = mapped_column(JSON, required=True, key="metadata")
__table_args__ = (
UniqueConstraint(
"span_rowid",
"name",
name="uq_span_annotations_span_rowid_name",
sqlite_on_conflict="UPDATE",
),
)

0 comments on commit 5d22906

Please sign in to comment.