Skip to content

Commit

Permalink
Add pydantic (All-Hands-AI#868)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Engel Nyst <[email protected]>
  • Loading branch information
3 people authored Apr 21, 2024
1 parent 900de87 commit 454e961
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 33 deletions.
49 changes: 27 additions & 22 deletions opendevin/schema/action.py
Original file line number Diff line number Diff line change
@@ -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()
29 changes: 18 additions & 11 deletions opendevin/schema/observation.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 454e961

Please sign in to comment.