🐛 fix(base.py): change frontend_node field in ValidatePromptRequest to use FrontendNodeRequest instead of FrontendNode

🔥 chore(base.py): remove unused FrontendNodeRequest class
🔨 refactor(validate.py): modify post_validate_prompt function to update the template field in the frontend_node object
The ValidatePromptRequest class was using the FrontendNode class instead of the FrontendNodeRequest class, which caused an error. The unused FrontendNodeRequest class was removed. The post_validate_prompt function was modified to update the template field in the frontend_node object instead of appending to the fields list.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-27 19:17:46 -03:00
commit e760f22847
2 changed files with 8 additions and 3 deletions

View file

@ -13,9 +13,13 @@ class Code(BaseModel):
code: str
class FrontendNodeRequest(FrontendNode):
template: dict
class ValidatePromptRequest(BaseModel):
template: str
frontend_node: FrontendNode
frontend_node: FrontendNodeRequest
# Build ValidationResponse class for {"imports": {"errors": []}, "function": {"errors": []}}
@ -34,7 +38,7 @@ class CodeValidationResponse(BaseModel):
class PromptValidationResponse(BaseModel):
input_variables: list
frontend_node: FrontendNode
frontend_node: FrontendNodeRequest
INVALID_CHARACTERS = {

View file

@ -36,7 +36,8 @@ def post_validate_prompt(prompt: ValidatePromptRequest):
template_field = TemplateField(
name=variable, field_type="str", show=True, advanced=False
)
prompt.frontend_node.template.fields.append(template_field)
prompt.frontend_node.template[variable] = template_field.dict()
prompt.frontend_node.custom_fields.append(variable)
except Exception as exc:
logger.exception(exc)