Download src/stage4/models.py from BBBAKERY/ustwo-api: direct link, hf CLI and curl.
- Browser
- Download file 2.21 kB
-
https://huggingface.co/spaces/BBBAKERY/ustwo-api/resolve/main/src/stage4/models.py
- Command line
-
hf download hf://spaces/BBBAKERY/ustwo-api/src/stage4/models.py
-
curl -L -o models.py https://huggingface.co/spaces/BBBAKERY/ustwo-api/resolve/main/src/stage4/models.py
2.21 kB
| """ | |
| SQLAlchemy models for UsTwo. | |
| Tables: | |
| calls β uploaded audio files + metadata | |
| analysis_results β Stage 3 output per call | |
| checkins β empathy check-in records | |
| garden_state β singleton garden progression | |
| """ | |
| from datetime import datetime, timezone | |
| from sqlalchemy import Column, String, Integer, Float, Text, DateTime, ForeignKey | |
| from .database import Base | |
| def _utcnow() -> datetime: | |
| return datetime.now(timezone.utc) | |
| class Call(Base): | |
| __tablename__ = "calls" | |
| id = Column(String, primary_key=True) # call_id (timestamp-based) | |
| audio_path = Column(String, nullable=False) | |
| duration = Column(Float, nullable=True) | |
| status = Column(String, default="uploaded") # uploaded β analyzing β done β error | |
| error_message = Column(Text, nullable=True) | |
| created_at = Column(DateTime, default=_utcnow) | |
| class AnalysisResult(Base): | |
| __tablename__ = "analysis_results" | |
| id = Column(Integer, primary_key=True, autoincrement=True) | |
| call_id = Column(String, ForeignKey("calls.id"), nullable=False) | |
| stage3_json = Column(Text, nullable=False) # full Stage3Output JSON | |
| blue_emotion = Column(String, nullable=True) # quick-query columns | |
| pink_emotion = Column(String, nullable=True) | |
| garden_delta = Column(Integer, default=0) | |
| created_at = Column(DateTime, default=_utcnow) | |
| class CheckIn(Base): | |
| __tablename__ = "checkins" | |
| id = Column(Integer, primary_key=True, autoincrement=True) | |
| iso_date = Column(String, nullable=False) # YYYY-MM-DD | |
| score = Column(Integer, nullable=False) | |
| level = Column(String, nullable=False) # deep/warm/growing/different/learning | |
| my_mood = Column(String, nullable=False) | |
| partner_guess = Column(String, nullable=False) | |
| created_at = Column(DateTime, default=_utcnow) | |
| class GardenState(Base): | |
| __tablename__ = "garden_state" | |
| id = Column(Integer, primary_key=True, default=1) # singleton (always id=1) | |
| interaction_count = Column(Integer, default=0) | |
| total_level = Column(Integer, default=1) | |
| last_mood = Column(String, default="happy") | |
| updated_at = Column(DateTime, default=_utcnow, onupdate=_utcnow) | |