Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4ef02b8
feat: enhance input validation for BaseNode by creating dynamic input…
srijanpatel Mar 14, 2025
bb59d3d
feat: introduce tool_function decorator for creating nodes/tools
srijanpatel Mar 14, 2025
7e4dbfc
docs: improve docstrings in NodeRegistry for clarity and consistency
srijanpatel Mar 14, 2025
153b03c
feat: enhance project initialization by creating custom directories a…
srijanpatel Mar 14, 2025
8e6b604
feat: implement tool function discovery in NodeRegistry to register f…
srijanpatel Mar 14, 2025
cc1aead
feat: add workflow builder and code handler for programmatic workflow…
srijanpatel Mar 14, 2025
cccd003
fix: base node composite inputs
JeanKaddour Mar 14, 2025
d0ca7e2
feat: add example script demonstrating custom tool functions using @t…
srijanpatel Mar 14, 2025
e65db83
feat: allow extra fields in BaseNodeConfig model configuration
srijanpatel Mar 14, 2025
170391e
Merge remote-tracking branch 'origin/fix/bugs' into feat/workflow-as-…
srijanpatel Mar 14, 2025
a22c249
fix: update input handling in WorkflowExecutor and clarify input type…
srijanpatel Mar 14, 2025
dbfd8f5
fix: correct input assignment in WorkflowExecutor to use node instanc…
srijanpatel Mar 14, 2025
619f25b
fix: update workflow code router tag to indicate beta status
srijanpatel Mar 14, 2025
89ad246
refactor: simplify docstrings in pydantic_utils.py for clarity
srijanpatel Mar 14, 2025
3bf1a1e
Update backend/pyspur/nodes/base.py
srijanpatel Mar 14, 2025
ec9cea7
Update backend/pyspur/examples/tool_function_example.py
srijanpatel Mar 14, 2025
9061b10
Update backend/pyspur/nodes/decorator.py
srijanpatel Mar 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: simplify docstrings in pydantic_utils.py for clarity
  • Loading branch information
srijanpatel committed Mar 14, 2025
commit 89ad246eb5552327201701f9a3959ee2b711ccb8
30 changes: 13 additions & 17 deletions backend/pyspur/utils/pydantic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@


def get_nested_field(field_name_with_dots: str, model: BaseModel) -> Any:
"""
Get the value of a nested field from a Pydantic model.
"""
"""Get the value of a nested field from a Pydantic model."""
field_names = field_name_with_dots.split(".")
value = model
for field_name in field_names:
Expand All @@ -18,9 +16,7 @@ def get_nested_field(field_name_with_dots: str, model: BaseModel) -> Any:


def get_jinja_template_for_model(model: BaseModel) -> str:
"""
Generate a Jinja template for a Pydantic model.
"""
"""Generate a Jinja template for a Pydantic model."""
template = "{\n"
for field_name, _field in model.model_fields.items():
template += f'"{field_name}": {{{{field_name}}}},\n'
Expand All @@ -33,16 +29,17 @@ def json_schema_to_model(
model_class_name: str = "Output",
base_class: Type[BaseModel] = BaseModel,
) -> Type[BaseModel]:
"""
Converts a JSON schema to a Pydantic BaseModel class.
"""Convert a JSON schema to a Pydantic BaseModel class.

Args:
json_schema: The JSON schema to convert.
model_class_name: The name of the model class to create.
base_class: The base class for the model (default is BaseModel).

Returns:
A Pydantic BaseModel class.
"""

"""
# Extract the model name from the schema title.
model_name = model_class_name

Expand All @@ -59,17 +56,17 @@ def json_schema_to_model(
def json_schema_to_pydantic_field(
name: str, json_schema: Dict[str, Any], required: List[str]
) -> Any:
"""
Converts a JSON schema property to a Pydantic field definition.
"""Convert a JSON schema property to a Pydantic field definition.

Args:
name: The field name.
json_schema: The JSON schema property.
required: A list of required fields.

Returns:
A Pydantic field definition.
"""

"""
# Get the field type.
type_ = json_schema_to_pydantic_type(json_schema)

Expand All @@ -92,16 +89,15 @@ def json_schema_to_pydantic_field(


def json_schema_to_pydantic_type(json_schema: Dict[str, Any]) -> Any:
"""
Converts a JSON schema type to a Pydantic type.
"""Convert a JSON schema type to a Pydantic type.

Args:
json_schema: The JSON schema to convert.

Returns:
A Pydantic type.
"""

"""
type_ = json_schema.get("type")

if type_ == "string":
Expand Down Expand Up @@ -134,14 +130,14 @@ def json_schema_to_pydantic_type(json_schema: Dict[str, Any]) -> Any:


def json_schema_to_simple_schema(json_schema: Dict[str, Any]) -> Dict[str, str]:
"""
Converts a JSON schema to a simple schema.
"""Convert a JSON schema to a simple schema.

Args:
json_schema: The JSON schema to convert.

Returns:
A simple schema.

"""
simple_schema: Dict[str, str] = {}

Expand Down