mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-03 17:10:10 +08:00
69bc799cd9
* Implement label task for initial prompts and replies * Resolve formatting * Include missing argument * Modify text_labels API to match new model, update DB schema accordingly * Send valid labels as part of label tasks * Send correctly formatted valid_labels list * Fix request format * Fix request details for text-frontend reply label task * Include message_id in tasks * Address review comments * Fix alembic tree
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from uuid import UUID, uuid4
|
|
|
|
import sqlalchemy as sa
|
|
import sqlalchemy.dialects.postgresql as pg
|
|
from sqlmodel import Field, SQLModel
|
|
|
|
|
|
class TextLabels(SQLModel, table=True):
|
|
__tablename__ = "text_labels"
|
|
|
|
id: Optional[UUID] = Field(
|
|
sa_column=sa.Column(
|
|
pg.UUID(as_uuid=True), primary_key=True, default=uuid4, server_default=sa.text("gen_random_uuid()")
|
|
),
|
|
)
|
|
user_id: UUID = Field(sa_column=sa.Column(pg.UUID(as_uuid=True), sa.ForeignKey("user.id"), nullable=False))
|
|
created_date: Optional[datetime] = Field(
|
|
sa_column=sa.Column(sa.DateTime(), nullable=False, server_default=sa.func.current_timestamp()),
|
|
)
|
|
api_client_id: UUID = Field(nullable=False, foreign_key="api_client.id")
|
|
text: str = Field(nullable=False, max_length=2**16)
|
|
message_id: Optional[UUID] = Field(
|
|
sa_column=sa.Column(pg.UUID(as_uuid=True), sa.ForeignKey("message.id"), nullable=True)
|
|
)
|
|
labels: dict[str, float] = Field(default={}, sa_column=sa.Column(pg.JSONB), nullable=False)
|