🔨 refactor(schemas.py): rename PredictRequest to InputRequest and remove message field, add TweaksRequest and UpdateTemplateRequest

 feat(schemas.py): add ProcessResponse schema to represent the response of the process endpoint
The PredictRequest schema has been renamed to InputRequest to better reflect its purpose. The message field has been removed as it is not needed. TweaksRequest has been added to represent the request body for the tweaks endpoint. UpdateTemplateRequest has been added to represent the request body for updating a template. ProcessResponse has been added to represent the response of the process endpoint, which returns a dictionary as the result.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-22 19:04:19 -03:00
commit d5d6f7be57

View file

@ -20,34 +20,48 @@ class ExportedFlow(BaseModel):
data: GraphData
class PredictRequest(BaseModel):
"""Predict request schema."""
class InputRequest(BaseModel):
input: dict
message: str
class TweaksRequest(BaseModel):
tweaks: Optional[Dict[str, Dict[str, str]]] = Field(default_factory=dict)
class Config:
schema_extra = {
"example": {
"message": "Hello, how are you?",
"tweaks": {
"dndnode_986363f0-4677-4035-9f38-74b94af5dd78": {
"name": "A tool name",
"description": "A tool description",
},
"dndnode_986363f0-4677-4035-9f38-74b94af57378": {
"template": "A {template}",
},
},
}
}
# class PredictRequest(BaseModel):
# """Predict request schema."""
# input: dict
# tweaks: Optional[Dict[str, Dict[str, str]]] = Field(default_factory=dict)
# class Config:
# schema_extra = {
# "example": {
# "input": {
# "question": "A question to process",
# "chat_history": ["A chat history", "Another chat history"],
# },
# "tweaks": {
# "Tool-Aclk2": {
# "name": "A tool name",
# "description": "A tool description",
# },
# "NodeName-2kclS": {
# "template": "A {template}",
# },
# },
# }
# }
class PredictResponse(BaseModel):
"""Predict response schema."""
class UpdateTemplateRequest(BaseModel):
template: dict
result: str
intermediate_steps: str = ""
class ProcessResponse(BaseModel):
"""Process response schema."""
result: dict
class ChatMessage(BaseModel):