forked from tilesprivacy/tiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemas.py
More file actions
75 lines (58 loc) · 1.84 KB
/
schemas.py
File metadata and controls
75 lines (58 loc) · 1.84 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from pydantic import BaseModel, Field
from typing import Any, Dict, List, Optional, Union
from dataclasses import dataclass
class CompletionRequest(BaseModel):
model: str
prompt: Union[str, List[str]]
max_tokens: Optional[int] = None
temperature: Optional[float] = 0.7
top_p: Optional[float] = 0.9
stream: Optional[bool] = False
stop: Optional[Union[str, List[str]]] = None
repetition_penalty: Optional[float] = 1.1
class ChatMessage(BaseModel):
role: str = Field(..., pattern="^(system|user|assistant)$")
content: str
class ChatCompletionRequest(BaseModel):
model: str
messages: List[ChatMessage]
chat_start: bool
python_code: str
max_tokens: Optional[int] = None
temperature: Optional[float] = 0.7
top_p: Optional[float] = 0.9
stream: Optional[bool] = False
stop: Optional[Union[str, List[str]]] = None
repetition_penalty: Optional[float] = 1.1
class CompletionResponse(BaseModel):
id: str
object: str = "text_completion"
created: int
model: str
choices: List[Dict[str, Any]]
usage: Dict[str, int]
class ChatCompletionResponse(BaseModel):
id: str
object: str = "chat.completion"
created: int
model: str
choices: List[Dict[str, Any]]
# usage: Dict[str, int]
class ModelInfo(BaseModel):
id: str
object: str = "model"
owned_by: str = "mlx-knife"
permission: List = []
context_length: Optional[int] = None
class StartRequest(BaseModel):
model: str
memory_path: str
class downloadRequest(BaseModel):
model: str
@dataclass
class GenerationMetrics:
"""Benchmarking metrics for token generation."""
ttft_ms: float # Time to first token in milliseconds
total_tokens: int # Total tokens generated
tokens_per_second: float # Throughput
total_latency_s: float # End-to-end latency in seconds