-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_body.py
89 lines (76 loc) · 2.33 KB
/
request_body.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from typing import (
Any,
Literal,
List,
Optional,
)
from pydantic import BaseModel, Field
class CompletionRequestBody(BaseModel):
"""_summary_
from from https://github.com/abetlen/llama-cpp-python/blob/main/llama_cpp/server/app.py
"""
prompt: str = Field(
default="", description="The prompt to generate completions for."
)
max_tokens: Optional[int]
temperature: Optional[float]
top_p: Optional[float]
stop: Optional[List[str] | str]
stream: Optional[bool] = Field()
model: str = Field()
# llama.cpp specific parameters
top_k: Optional[int]
repetition_penalty: Optional[float]
frequency_penalty: Optional[float]
last_n_tokens: Optional[int]
seed: Optional[int]
batch_size: Optional[int]
threads: Optional[int]
# ignored or currently unsupported
suffix: Any
presence_penalty: Any
echo: Any
n: Any
logprobs: Any
best_of: Any
logit_bias: Any
user: Any
class Config:
arbitrary_types_allowed = True
class ChatCompletionRequestMessage(BaseModel):
"""_summary_
from from https://github.com/abetlen/llama-cpp-python/blob/main/llama_cpp/server/app.py
"""
role: Literal["system", "user", "assistant"] = Field(
default="user", description="The role of the message."
)
content: str = Field(default="", description="The content of the message.")
class ChatCompletionRequestBody(BaseModel):
"""_summary_
Request body for /chat/completions.
from from https://github.com/abetlen/llama-cpp-python/blob/main/llama_cpp/server/app.py
"""
messages: List[ChatCompletionRequestMessage] = Field(
default=[], description="A list of messages to generate completions for."
)
max_tokens: Optional[int]
temperature: Optional[float]
top_p: Optional[float]
stop: Optional[List[str] | str]
stream: Optional[bool] = Field()
model: str = Field()
# llama.cpp specific parameters
top_k: Optional[int]
repetition_penalty: Optional[float]
frequency_penalty: Optional[float]
last_n_tokens: Optional[int]
seed: Optional[int]
batch_size: Optional[int]
threads: Optional[int]
# ignored or currently unsupported
n: Any
logit_bias: Any
user: Any
presence_penalty: Any
class Config:
arbitrary_types_allowed = True