Skip to content

Commit 38bd893

Browse files
committed
generated file: core/models/models.py
1 parent b349f75 commit 38bd893

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

core/models/models.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from pydantic import BaseModel, validator
2+
3+
class RequestBody(BaseModel):
4+
text: str
5+
model: str
6+
7+
@validator("text")
8+
def text_cannot_be_empty(cls, value):
9+
if not value.strip():
10+
raise ValueError("Text cannot be empty.")
11+
return value
12+
13+
@validator("model")
14+
def model_must_be_valid(cls, value):
15+
allowed_models = ["gpt-3.5-turbo", "text-davinci-003", "code-davinci-002", "gpt-4"]
16+
if value not in allowed_models:
17+
raise ValueError("Invalid model name.")
18+
return value
19+
20+
class ResponseModel(BaseModel):
21+
text: str

0 commit comments

Comments
 (0)