Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 38f5b75

Browse files
committed
v0.0.13
1 parent 7f8e251 commit 38f5b75

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/),
66
and this project adheres to [SimpleTool](https://github.com/nchekwa/simpletool-python/tree/master).
77

8+
# [0.0.13] - 2025-01-08 Milestone Alpha2
9+
10+
## Fixed
11+
- Updated test import from `BoolContents` to `BoolContent` to match type definition
12+
813

914
# [0.0.12] - 2025-01-08 Milestone Alpha2
1015

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22

33
setup(name='simpletool',
4-
version='0.0.12',
4+
version='0.0.13',
55
description='simpletool',
66
url='https://github.com/nchekwa/simpletool-python/tree/master',
77
author='Artur Zdolinski',

simpletool/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
from typing import Optional, TypeVar, AnyStr, Callable, Awaitable, Coroutine, ClassVar # noqa: F401, F403
1414
from pydantic import BaseModel, Field
1515
from pydantic.fields import FieldInfo
16-
from .types import Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContents, ErrorContent
16+
from .types import Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContent, ErrorContent
1717
from .models import SimpleInputModel
1818
from .schema import NoTitleDescriptionJsonSchema
1919
from .errors import SimpleToolError, ValidationError
2020

2121

2222
def get_valid_content_types() -> Tuple[Type, ...]:
2323
"""Directly return the types from the TypeVar definition as a tuple"""
24-
return (Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContents, ErrorContent)
24+
return (Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContent, ErrorContent)
2525

2626

2727
def validate_tool_output(func):
2828
@functools.wraps(func)
29-
async def wrapper(*args: Any, **kwargs: Any) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContents, ErrorContent]]:
29+
async def wrapper(*args: Any, **kwargs: Any) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContent, ErrorContent]]:
3030
result = await func(*args, **kwargs)
3131
if not isinstance(result, list):
3232
raise ValidationError("output", "Tool output must be a list")
@@ -204,7 +204,7 @@ def __repr__(self):
204204

205205
@validate_tool_output
206206
@set_timeout(DEFAULT_TIMEOUT)
207-
async def run(self, arguments: Dict[str, Any]) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContents, ErrorContent]]:
207+
async def run(self, arguments: Dict[str, Any]) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContent, ErrorContent]]:
208208
"""
209209
Execute the tool with the given arguments.
210210
@@ -250,7 +250,7 @@ async def run(self, arguments: Dict[str, Any]) -> Sequence[Union[Content, TextCo
250250
# No timeout if _timeout is 0 or negative
251251
return await self._run_implementation(validated_arguments)
252252

253-
async def _run_implementation(self, arguments: SimpleInputModel) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContents, ErrorContent]]:
253+
async def _run_implementation(self, arguments: SimpleInputModel) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContent, ErrorContent]]:
254254
"""
255255
Actual implementation of the tool's run method.
256256
Must be implemented by child classes.
@@ -263,7 +263,7 @@ async def _run_implementation(self, arguments: SimpleInputModel) -> Sequence[Uni
263263
"""
264264
raise SimpleToolError(f"Subclass {self.__class__.__name__} must implement _run_implementation method")
265265

266-
async def __call__(self, arguments: Dict[str, Any]) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContents, ErrorContent]]:
266+
async def __call__(self, arguments: Dict[str, Any]) -> Sequence[Union[Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContent, ErrorContent]]:
267267
"""Alias for run method"""
268268
return await self.run(arguments)
269269

simpletool/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ErrorContent(Content):
123123
model_config = ConfigDict(extra="allow")
124124

125125

126-
class BoolContents(Content):
126+
class BoolContent(Content):
127127
type: Literal["blob"] = "blob" # type: ignore
128128
bool: bool
129129
description: Optional[str] | None = None

tests/test_simpletool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ResourceContent,
2121
ErrorContent,
2222
Content,
23-
BoolContents
23+
BoolContent
2424
)
2525
from simpletool.errors import ValidationError
2626

@@ -45,7 +45,7 @@ def test_get_valid_content_types():
4545
"""Test get_valid_content_types function."""
4646
valid_types = get_valid_content_types()
4747
assert len(valid_types) == 7
48-
assert set(valid_types) == {Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContents, ErrorContent}
48+
assert set(valid_types) == {Content, TextContent, ImageContent, FileContent, ResourceContent, BoolContent, ErrorContent}
4949

5050

5151
def test_validate_tool_output_decorator():

tests/test_types.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
ImageContent,
1010
FileContent,
1111
ResourceContent,
12-
ErrorContent
12+
ErrorContent,
13+
BoolContent
1314
)
1415

1516

@@ -132,3 +133,21 @@ def test_error_data():
132133
assert error.code == 404
133134
assert error.message == "Resource not found"
134135
assert error.data == {"details": "Additional error info"}
136+
137+
138+
def test_bool_content():
139+
"""Test BoolContent model."""
140+
bool_content = BoolContent(type="blob", bool=True)
141+
assert bool_content.type == "blob"
142+
assert bool_content.bool is True
143+
144+
bool_content_from_bool = BoolContent(**{"bool": True})
145+
assert bool_content_from_bool.bool is True
146+
147+
bool_content_with_desc = BoolContent(
148+
type="blob",
149+
bool=False,
150+
description="A boolean content"
151+
)
152+
assert bool_content_with_desc.bool is False
153+
assert bool_content_with_desc.description == "A boolean content"

0 commit comments

Comments
 (0)