File size: 643 Bytes
759bf41
b42781c
 
759bf41
 
 
 
 
9668975
759bf41
b42781c
759bf41
b42781c
759bf41
 
 
 
f25fee8
 
 
b42781c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from datetime import UTC, datetime
from zoneinfo import ZoneInfo

ORG = "bee2link"
MODEL_SEARCH = "breakdown-risk-"
DATASET_REPO = "bee2link/breakdown-risk"
CALLER_TURNS = 3
REFRESH_SECONDS = 30
TOKEN = os.environ.get("HF_TOKEN")
PARIS = ZoneInfo("Europe/Paris")

LABEL_NAMES = {"risk": "Breakdown risk", "no_risk": "No risk"}


def display(label: str) -> str:
    return LABEL_NAMES.get(label, label)


def stamp(when: datetime) -> str:
    """One timestamp format everywhere, in Paris time; the Hub reports UTC."""
    utc = when if when.tzinfo else when.replace(tzinfo=UTC)
    return f"{utc.astimezone(PARIS):%Y-%m-%d %H:%M %Z}"