Skip to content

Commit

Permalink
refactor(tools): enhance type annotations and clean up variable usage
Browse files Browse the repository at this point in the history
- Changed `VariableKey` to inherit from `str` and `Enum` for better compatibility.
- Updated the type annotation of `meta` in `create_blob_message` to use more modern syntax.
- Removed unnecessary `.value` in `save_as` parameter for cleaner code.
  • Loading branch information
laipz8200 committed Oct 9, 2024
1 parent 22a1cc7 commit 576d593
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/core/tools/provider/builtin/dalle/tools/dalle3.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _invoke(
for image in response.data:
mime_type, blob_image = DallE3Tool._decode_image(image.b64_json)
blob_message = self.create_blob_message(
blob=blob_image, meta={"mime_type": mime_type}, save_as=self.VariableKey.IMAGE.value
blob=blob_image, meta={"mime_type": mime_type}, save_as=self.VariableKey.IMAGE
)
result.append(blob_message)
return result
Expand Down
2 changes: 1 addition & 1 deletion api/core/tools/tool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, **data: Any):
def __init__(self, **data: Any):
super().__init__(**data)

class VariableKey(Enum):
class VariableKey(str, Enum):
IMAGE = "image"

def fork_tool_runtime(self, runtime: dict[str, Any]) -> "Tool":
Expand Down

0 comments on commit 576d593

Please sign in to comment.