From 454e9613b0b4c7a9dbb2b8273aff0b36c4d8a2bb Mon Sep 17 00:00:00 2001 From: yaroslavMain <122780614+yaroslavMain@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:41:04 +0300 Subject: [PATCH] Add pydantic (#868) * Update action.py * Update observation.py * Update observation.py * Update action.py * Update observation.py * Update opendevin/schema/action.py * Update action.py * Update observation.py * Update action.py * Update observation.py * Update observation.py * Update observation.py * Update observation.py * Update action.py * Update action.py * Update action.py * Update observation.py * Update observation.py --------- Co-authored-by: Robert Brennan Co-authored-by: Engel Nyst --- opendevin/schema/action.py | 49 ++++++++++++++++++--------------- opendevin/schema/observation.py | 29 +++++++++++-------- 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/opendevin/schema/action.py b/opendevin/schema/action.py index 7f55e4c70f0b..9c3fe30aefea 100644 --- a/opendevin/schema/action.py +++ b/opendevin/schema/action.py @@ -1,68 +1,73 @@ -from enum import Enum +from pydantic import BaseModel, Field +__all__ = [ + 'ActionType' +] -class ActionType(str, Enum): - INIT = 'initialize' + +class ActionTypeSchema(BaseModel): + INIT: str = Field(default='initialize') """Initializes the agent. Only sent by client. """ - START = 'start' + START: str = Field(default='start') """Starts a new development task. Only sent by the client. """ - READ = 'read' + READ: str = Field(default='read') """Reads the content of a file. """ - WRITE = 'write' + WRITE: str = Field(default='write') """Writes the content to a file. """ - RUN = 'run' + RUN: str = Field(default='run') """Runs a command. """ - KILL = 'kill' + KILL: str = Field(default='kill') """Kills a background command. """ - BROWSE = 'browse' + BROWSE: str = Field(default='browse') """Opens a web page. """ - RECALL = 'recall' + RECALL: str = Field(default='recall') """Searches long-term memory """ - THINK = 'think' + THINK: str = Field(default='think') """Allows the agent to make a plan, set a goal, or record thoughts """ - FINISH = 'finish' + FINISH: str = Field(default='finish') """If you're absolutely certain that you've completed your task and have tested your work, use the finish action to stop working. """ - CHAT = 'chat' - - SUMMARIZE = 'summarize' + NULL: str = Field(default='null') - ADD_TASK = 'add_task' + SUMMARIZE: str = Field(default='summarize') - MODIFY_TASK = 'modify_task' + ADD_TASK: str = Field(default='add_task') - NULL = 'null' + MODIFY_TASK: str = Field(default='modify_task') - PAUSE = 'pause' + PAUSE: str = Field(default='pause') """Pauses the task. """ - RESUME = 'resume' + RESUME: str = Field(default='resume') """Resumes the task. """ - STOP = 'stop' + STOP: str = Field(default='stop') """Stops the task. Must send a start action to restart a new task. """ - CHANGE_TASK_STATE = 'change_task_state' + CHANGE_TASK_STATE: str = Field(default='change_task_state') + + +ActionType = ActionTypeSchema() diff --git a/opendevin/schema/observation.py b/opendevin/schema/observation.py index fb79afe2ee17..6f7944e3a7ea 100644 --- a/opendevin/schema/observation.py +++ b/opendevin/schema/observation.py @@ -1,31 +1,38 @@ -from enum import Enum +from pydantic import BaseModel, Field +__all__ = [ + 'ObservationType' +] -class ObservationType(str, Enum): - READ = 'read' + +class ObservationTypeSchema(BaseModel): + READ: str = Field(default='read') """The content of a file """ - WRITE = 'write' + WRITE: str = Field(default='write') - BROWSE = 'browse' + BROWSE: str = Field(default='browse') """The HTML content of a URL """ - RUN = 'run' + RUN: str = Field(default='run') """The output of a command """ - RECALL = 'recall' + RECALL: str = Field(default='recall') """The result of a search """ - CHAT = 'chat' + CHAT: str = Field(default='chat') """A message from the user """ - MESSAGE = 'message' + MESSAGE: str = Field(default='message') + + ERROR: str = Field(default='error') + + NULL: str = Field(default='null') - ERROR = 'error' - NULL = 'null' +ObservationType = ObservationTypeSchema()