jonathanjordan21 commited on
Commit
122cc54
·
verified ·
1 Parent(s): 1f28a77

Create app/schemas.py

Browse files
Files changed (1) hide show
  1. app/schemas.py +59 -0
app/schemas.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from pydantic import BaseModel, Field
3
+ from typing import Literal
4
+
5
+
6
+ class AnalysisRequest(BaseModel):
7
+ text: str = Field(min_length=1, max_length=10000)
8
+
9
+ entity_labels: list[str] = Field(
10
+ default=[
11
+ "person",
12
+ "organization",
13
+ "location",
14
+ "date",
15
+ "product",
16
+ "money"
17
+ ],
18
+ max_length=25
19
+ )
20
+
21
+ entity_threshold: float = Field(
22
+ default=0.5,
23
+ ge=0,
24
+ le=1
25
+ )
26
+
27
+
28
+ class EmbeddingRequest(BaseModel):
29
+ input: list[str] = Field(
30
+ min_length=1,
31
+ max_length=128
32
+ )
33
+
34
+ dimensions: int | None = Field(
35
+ default=None,
36
+ ge=32,
37
+ le=768
38
+ )
39
+
40
+ precision: Literal[
41
+ "float32",
42
+ "float16",
43
+ "int8"
44
+ ] = "float32"
45
+
46
+ normalize: bool = True
47
+
48
+
49
+ class AnalysisResponse(BaseModel):
50
+ entities: list[dict]
51
+ sentiment: dict
52
+ sarcasm: dict
53
+
54
+
55
+ class EmbeddingResponse(BaseModel):
56
+ dimensions: int
57
+ precision: str
58
+ embeddings: list[list[float] | list[int]]
59
+ scales: list[float] | None = None