File size: 1,307 Bytes
122cc54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0676474
 
 
 
 
e86a8da
 
 
 
 
122cc54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

from pydantic import BaseModel, Field
from typing import Literal


class AnalysisRequest(BaseModel):
    text: str = Field(min_length=1, max_length=10000)

    entity_labels: list[str] = Field(
        default=[
            "person",
            "organization",
            "location",
            "date",
            "product",
            "money"
        ],
        max_length=25
    )

    entity_threshold: float = Field(
        default=0.5,
        ge=0,
        le=1
    )



class SarcasmRequest(BaseModel):
    text: str = Field(min_length=1, max_length=5000)


class AbsaRequest(BaseModel):
    text: str = Field(min_length=1, max_length=5000)
    aspect: str = Field(min_length=1, max_length=100)


class EmbeddingRequest(BaseModel):
    input: list[str] = Field(
        min_length=1,
        max_length=128
    )

    dimensions: int | None = Field(
        default=None,
        ge=32,
        le=768
    )

    precision: Literal[
        "float32",
        "float16",
        "int8"
    ] = "float32"

    normalize: bool = True


class AnalysisResponse(BaseModel):
    entities: list[dict]
    sentiment: dict
    sarcasm: dict


class EmbeddingResponse(BaseModel):
    dimensions: int
    precision: str
    embeddings: list[list[float] | list[int]]
    scales: list[float] | None = None