Skip to content

Commit

Permalink
Refactor BaseNode to handle additional field types in output schema
Browse files Browse the repository at this point in the history
  • Loading branch information
srijanpatel committed Jan 26, 2025
1 parent 1533a57 commit 74d56b5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/app/nodes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,28 @@ def create_output_model_class(
"""
field_type_to_python_type = {
"string": str,
"str": str,
"integer": int,
"int": int,
"number": float,
"float": float,
"boolean": bool,
"bool": bool,
"list": list,
"dict": dict,
"array": list,
"object": dict,
}
return create_model(
f"{self.name}",
**{field_name: (field_type_to_python_type[field_type], ...) for field_name, field_type in output_schema.items()}, # type: ignore
**{
field_name: (
(field_type_to_python_type[field_type], ...)
if field_type in field_type_to_python_type
else (field_type, ...) # try as is
)
for field_name, field_type in output_schema.items()
}, # type: ignore
__base__=BaseNodeOutput,
)

Expand Down

0 comments on commit 74d56b5

Please sign in to comment.