Skip to content

Commit

Permalink
Raising value error on more than one field for interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Rusia committed Nov 15, 2024
1 parent 7f385ca commit f1bbae5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
authors = [{ name = "Aman Rusia", email = "[email protected]" }]
name = "wcgw"
version = "1.0.2"
version = "1.0.3"
description = "What could go wrong giving full shell access to chatgpt?"
readme = "README.md"
requires-python = ">=3.10, <3.13"
Expand Down
16 changes: 16 additions & 0 deletions src/wcgw/types_.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ class BashInteraction(BaseModel):
send_specials: Optional[Sequence[Specials]] = None
send_ascii: Optional[Sequence[int]] = None

def model_post_init(self, __context: object) -> None:
# Ensure only one of the fields is set
if (
sum(
[
int(bool(self.send_text)),
int(bool(self.send_specials)),
int(bool(self.send_ascii)),
]
)
!= 1
):
raise ValueError(
"Exactly one of 'send_text', 'send_specials', or 'send_ascii' must be set"
)


class ReadImage(BaseModel):
file_path: str
Expand Down

0 comments on commit f1bbae5

Please sign in to comment.