From 02a0367757b665171e9dff28fe434713382f2b92 Mon Sep 17 00:00:00 2001 From: iFurySt Date: Wed, 27 Mar 2024 00:06:30 +0800 Subject: [PATCH] feat: add message related schema to FE and BE. (#195) --- frontend/src/types/ActionType.tsx | 34 ++++++++++++++++++++ frontend/src/types/Message.tsx | 24 ++++++++++++++ frontend/src/types/ObservationType.tsx | 18 +++++++++++ opendevin/server/schema/action.py | 44 ++++++++++++++++++++++++++ opendevin/server/schema/observation.py | 23 ++++++++++++++ 5 files changed, 143 insertions(+) create mode 100644 frontend/src/types/ActionType.tsx create mode 100644 frontend/src/types/Message.tsx create mode 100644 frontend/src/types/ObservationType.tsx create mode 100644 opendevin/server/schema/action.py create mode 100644 opendevin/server/schema/observation.py diff --git a/frontend/src/types/ActionType.tsx b/frontend/src/types/ActionType.tsx new file mode 100644 index 000000000000..fa668549b515 --- /dev/null +++ b/frontend/src/types/ActionType.tsx @@ -0,0 +1,34 @@ +enum ActionType { + // Initializes the agent. Only sent by client. + INIT = "initialize", + + // Starts a new development task. Only sent by the client. + START = "start", + + // Reads the contents of a file. + READ = "read", + + // Writes the contents to a file. + WRITE = "write", + + // Runs a command. + RUN = "run", + + // Kills a background command. + KILL = "kill", + + // Opens a web page. + BROWSE = "browse", + + // Searches long-term memory. + RECALL = "recall", + + // Allows the agent to make a plan, set a goal, or record thoughts. + THINK = "think", + + // If you're absolutely certain that you've completed your task and have tested your work, + // use the finish action to stop working. + FINISH = "finish", +} + +export default ActionType; diff --git a/frontend/src/types/Message.tsx b/frontend/src/types/Message.tsx new file mode 100644 index 000000000000..1ff375e9050a --- /dev/null +++ b/frontend/src/types/Message.tsx @@ -0,0 +1,24 @@ +export interface ActionMessage { + // The action to be taken + action: string; + + // The arguments for the action + args: Record; + + // A friendly message that can be put in the chat log + message: string; +} + +export interface ObservationMessage { + // The type of observation + observation: string; + + // The observed data + content: string; + + // Additional structured data + extras: Record; + + // A friendly message that can be put in the chat log + message: string; +} diff --git a/frontend/src/types/ObservationType.tsx b/frontend/src/types/ObservationType.tsx new file mode 100644 index 000000000000..b86bd58919d2 --- /dev/null +++ b/frontend/src/types/ObservationType.tsx @@ -0,0 +1,18 @@ +enum ObservationType { + // The contents of a file + READ = "read", + + // The HTML contents of a URL + BROWSE = "browse", + + // The output of a command + RUN = "run", + + // The result of a search + RECALL = "recall", + + // A message from the user + CHAT = "chat", +} + +export default ObservationType; diff --git a/opendevin/server/schema/action.py b/opendevin/server/schema/action.py new file mode 100644 index 000000000000..d93384ec3075 --- /dev/null +++ b/opendevin/server/schema/action.py @@ -0,0 +1,44 @@ +from enum import Enum + + +class ActionType(str, Enum): + INIT = "initialize" + """Initializes the agent. Only sent by client. + """ + + START = "start" + """Starts a new development task. Only sent by the client. + """ + + READ = "read" + """Reads the contents of a file. + """ + + WRITE = "write" + """Writes the contents to a file. + """ + + RUN = "run" + """Runs a command. + """ + + KILL = "kill" + """Kills a background command. + """ + + BROWSE = "browse" + """Opens a web page. + """ + + RECALL = "recall" + """Searches long-term memory + """ + + THINK = "think" + """Allows the agent to make a plan, set a goal, or record thoughts + """ + + FINISH = "finish" + """If you're absolutely certain that you've completed your task and have tested your work, + use the finish action to stop working. + """ diff --git a/opendevin/server/schema/observation.py b/opendevin/server/schema/observation.py new file mode 100644 index 000000000000..74450ab0a714 --- /dev/null +++ b/opendevin/server/schema/observation.py @@ -0,0 +1,23 @@ +from enum import Enum + + +class ObservationType(str, Enum): + READ = "read" + """The contents of a file + """ + + BROWSE = "browse" + """The HTML contents of a URL + """ + + RUN = "run" + """The output of a command + """ + + RECALL = "recall" + """The result of a search + """ + + CHAT = "chat" + """A message from the user + """