-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
49 lines (31 loc) · 1.38 KB
/
models.py
File metadata and controls
49 lines (31 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from typing import Dict, List, Optional
from pydantic import BaseModel, Field
class PaperInput(BaseModel):
title: str
abstract_inverted_index: Dict[str, List[int]]
journal_display_name: str
referenced_works: List[str]
inverted: bool
abstract: Optional[str] = None
class TopicPrediction(BaseModel):
"""Single topic prediction with ID, label and confidence score"""
topic_id: int = Field(..., description="Topic identifier")
topic_label: Optional[str] = Field(None, description="Human-readable topic label")
topic_score: float = Field(..., description="Confidence score between 0 and 1")
class SinglePaperPrediction(BaseModel):
"""Single paper prediction with list of topic predictions and scores"""
predictions: List[TopicPrediction] = Field(
..., description="List of predictions for the paper"
)
class HealthCheckResponse(BaseModel):
"""Health check response model"""
status: str = Field(..., description="Service health status")
model: str = Field(..., description="Model status")
class BatchPaperPredictions(BaseModel):
"""Response schema for topic predictions for papers"""
predictions: List[List[TopicPrediction]] = Field(
..., description="List of predictions for each paper"
)
class ErrorResponse(BaseModel):
"""Error response model"""
Error: str = Field(..., description="Error message")