Skip to content

Commit

Permalink
Removed type requirement from types
Browse files Browse the repository at this point in the history
  • Loading branch information
rusiaaman committed Dec 30, 2024
1 parent afae1bd commit 0ac067f
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 226 deletions.
4 changes: 2 additions & 2 deletions src/wcgw/client/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ def take_help_of_ai_assistant(


def which_tool(args: str) -> TOOLS:
adapter = TypeAdapter[TOOLS](TOOLS)
adapter = TypeAdapter[TOOLS](TOOLS, config={"extra": "forbid"})
return adapter.validate_python(json.loads(args))


Expand Down Expand Up @@ -1180,7 +1180,7 @@ def get_tool_output(
) -> tuple[list[str | ImageData | DoneFlag], float]:
global IS_IN_DOCKER, TOOL_CALLS
if isinstance(args, dict):
adapter = TypeAdapter[TOOLS](TOOLS)
adapter = TypeAdapter[TOOLS](TOOLS, config={"extra": "forbid"})
arg = adapter.validate_python(args)
else:
arg = args
Expand Down
17 changes: 9 additions & 8 deletions src/wcgw/types_.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from typing import Literal, Optional, Sequence

from pydantic import BaseModel
from pydantic import BaseModel as PydanticBaseModel


class NoExtraArgs(PydanticBaseModel):
class Config:
extra = "forbid"


BaseModel = NoExtraArgs


class BashCommand(BaseModel):
Expand All @@ -14,7 +22,6 @@ class BashCommand(BaseModel):


class BashInteraction(BaseModel):
type: Literal["BashInteraction"]
send_text: Optional[str] = None
send_specials: Optional[Sequence[Specials]] = None
send_ascii: Optional[Sequence[int]] = None
Expand All @@ -23,7 +30,6 @@ class BashInteraction(BaseModel):

class ReadImage(BaseModel):
file_path: str
type: Literal["ReadImage"]


class WriteIfEmpty(BaseModel):
Expand All @@ -33,7 +39,6 @@ class WriteIfEmpty(BaseModel):

class ReadFiles(BaseModel):
file_paths: list[str]
type: Literal["ReadFiles"]


class FileEditFindReplace(BaseModel):
Expand All @@ -52,26 +57,22 @@ class FileEdit(BaseModel):


class Initialize(BaseModel):
type: Literal["Initialize"]
any_workspace_path: str
initial_files_to_read: list[str]


class GetScreenInfo(BaseModel):
type: Literal["GetScreenInfo"]
docker_image_id: str


class ScreenShot(BaseModel):
type: Literal["ScreenShot"]
take_after_delay_seconds: int


class MouseMove(BaseModel):
x: int
y: int
do_left_click_on_move: bool
type: Literal["MouseMove"]


class LeftClickDrag(BaseModel):
Expand Down
Loading

0 comments on commit 0ac067f

Please sign in to comment.