-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.py
46 lines (31 loc) · 817 Bytes
/
api.py
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
from pydantic import BaseModel
from typing import List, Dict, Optional
class ProcessRequest(BaseModel):
prompt: str
num_samples: int = 1
max_new_tokens: int = 50
top_k: int = 200
temperature: float = 0.8
seed: Optional[int] = None
echo_prompt: Optional[bool]
class Token(BaseModel):
text: str
logprob: float
top_logprob: Dict[str, float]
class ProcessResponse(BaseModel):
text: str
tokens: List[Token]
logprob: float
request_time: float
class TokenizeRequest(BaseModel):
text: str
truncation: bool = True
max_length: int = 2048
class TokenizeResponse(BaseModel):
tokens: List[int]
request_time: float
class DecodeRequest(BaseModel):
tokens: List[int]
class DecodeResponse(BaseModel):
text: str
request_time: float