Skip to content

Commit

Permalink
Update version to 0.1.2 in pyproject.toml and modify Toolkit class in…
Browse files Browse the repository at this point in the history
… toolkit.py to allow 'tools' to be optional, adding a field validator for better handling of None values.
  • Loading branch information
kuerbis-h committed Jan 16, 2025
1 parent 5fe109c commit 75354d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pyramidpy-tools"
version = "0.1.1"
version = "0.1.2"
description = "Toolkits for the PyramidPy Project"
requires-python = ">=3.10.10"
authors = [{name = "PyramidPy Team"}]
Expand Down
10 changes: 8 additions & 2 deletions src/pyramidpy_tools/toolkit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, List, Literal, TypeVar

from controlflow.tools.tools import Tool
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, field_validator

BaseType = TypeVar("BaseType", bound=BaseModel)

Expand All @@ -14,7 +14,7 @@ class Toolkit(BaseModel):
default: bool = Field(
description="Default toolkits available to all agents", default=True
)
tools: List[Tool] = Field(
tools: List[Tool] | None = Field(
description="List of tools in the toolkit", default=[]
)
requires_config: bool = Field(
Expand Down Expand Up @@ -68,6 +68,12 @@ class Toolkit(BaseModel):
description="Set to true if toolkit has configuration", default=False
)

@field_validator("tools", mode="after")
def validate_tools(cls, v):
if v is None:
return []
return v

def to_tool_list(self) -> List[Tool]:
tools = []
if self.active_tools not in [None, "all"]:
Expand Down

0 comments on commit 75354d0

Please sign in to comment.