Skip to content

Commit

Permalink
modified: simpletool/__init__.py
Browse files Browse the repository at this point in the history
	modified:   simpletool/types.py
  • Loading branch information
azdolinski committed Jan 2, 2025
1 parent 854cb01 commit 4abc0be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion simpletool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def execute(self, arguments: Dict[str, Any]) -> Union[List[Union[ImageCont
# Fallback to default implementation
raise NotImplementedError("Tool must implement either 'run' or 'execute' async method")

def _select_random_api_key(self, env_name:str, env_value: str) -> str:
def _select_random_api_key(self, env_name: str, env_value: str) -> str:
""" Select random api key from env_value only if env_name contains 'API' and 'KEY' """
if 'API' in env_name.upper() and 'KEY' in env_name.upper():
api_keys = list(filter(bool, [key.strip() for key in env_value.split(',')]))
Expand Down
10 changes: 8 additions & 2 deletions simpletool/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,39 @@ class Content(BaseModel):
type: Literal["text", "image", "resource"]
model_config = ConfigDict(extra="allow")


class TextContent(BaseModel):
"""Text content for a message."""
type: Literal["text"]
text: str
model_config = ConfigDict(extra="allow")


class ImageContent(BaseModel):
"""Image content for a message."""
type: Literal["image"]
data: str
mime_type: str = Field(alias="mimeType")
model_config = ConfigDict(extra="allow")


class ResourceContents(BaseModel):
"""The contents of a resource, embedded into a prompt or tool call result."""
uri: AnyUrl
mime_type: str | None = Field(None, alias="mimeType")
model_config = ConfigDict(extra="allow")


class TextResourceContents(ResourceContents):
""" Tee contents of a text resource, embedded into a prompt or tool call result."""
text: str


class BlobResourceContents(ResourceContents):
""" The contents of a blob resource, embedded into a prompt or tool call result."""
blob: str


class EmbeddedResource(BaseModel):
"""
The contents of a resource, embedded into a prompt or tool call result.
Expand All @@ -52,5 +58,5 @@ class ErrorData(BaseModel):
"""Error information for JSON-RPC error responses."""
code: int = Field(description="A number that indicates the error type that occurred.")
message: str = Field(description="A short description of the error. The message SHOULD be limited to a concise single sentence.")
data: Any | None = Field(default=None, description="Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).")
model_config = ConfigDict(extra="allow")
data: Any | None = Field(default=None, description="Additional information about the error.")
model_config = ConfigDict(extra="allow")

0 comments on commit 4abc0be

Please sign in to comment.