Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Add pydantic (#868)

yaroslavMain454e9613b0b4
diff --git a/opendevin/schema/action.py b/opendevin/schema/action.py
index 7f55e4c70f..9c3fe30aef 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 fb79afe2ee..6f7944e3a7 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()