mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 13:52:43 +08:00
* Merge branch 'main' of https://github.com/JayQuimby/OpenDevin * Using commands.sh for ACI * parsing, prompting, and actions modifications * added start and end index to read and write * bug fixes and test updates * Lint code changes to ensure code is proper * State management, bugs, prompts * Prompt Engineering * exception handling * big fixes * more bug fixes * merge conflicts * Renamed SWEAgent, basic tests, bug fixes * prompt changes, bug fixes * merge conflicts * merge conflict * start and end line for read and write * more merge conflicts * env error * linter error * read fixed, prompt change, example added * added x_line:end read operation --------- Co-authored-by: Robert Brennan <accounts@rbren.io>
78 lines
1.9 KiB
Python
78 lines
1.9 KiB
Python
from dataclasses import dataclass
|
|
from typing import TYPE_CHECKING
|
|
|
|
from opendevin.observation import (
|
|
AgentRecallObservation,
|
|
AgentMessageObservation,
|
|
Observation,
|
|
)
|
|
from opendevin.schema import ActionType
|
|
from .base import ExecutableAction, NotExecutableAction
|
|
|
|
if TYPE_CHECKING:
|
|
from opendevin.controller import AgentController
|
|
|
|
|
|
@dataclass
|
|
class AgentRecallAction(ExecutableAction):
|
|
query: str
|
|
action: str = ActionType.RECALL
|
|
|
|
async def run(self, controller: 'AgentController') -> AgentRecallObservation:
|
|
return AgentRecallObservation(
|
|
content='Recalling memories...',
|
|
memories=controller.agent.search_memory(self.query),
|
|
)
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return f"Let me dive into my memories to find what you're looking for! Searching for: '{self.query}'. This might take a moment."
|
|
|
|
|
|
@dataclass
|
|
class AgentThinkAction(NotExecutableAction):
|
|
thought: str
|
|
action: str = ActionType.THINK
|
|
|
|
async def run(self, controller: 'AgentController') -> 'Observation':
|
|
raise NotImplementedError
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return self.thought
|
|
|
|
|
|
@dataclass
|
|
class AgentEchoAction(ExecutableAction):
|
|
content: str
|
|
action: str = 'echo'
|
|
|
|
async def run(self, controller: 'AgentController') -> 'Observation':
|
|
return AgentMessageObservation(self.content)
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return self.content
|
|
|
|
|
|
@dataclass
|
|
class AgentSummarizeAction(NotExecutableAction):
|
|
summary: str
|
|
action: str = ActionType.SUMMARIZE
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return self.summary
|
|
|
|
|
|
@dataclass
|
|
class AgentFinishAction(NotExecutableAction):
|
|
action: str = ActionType.FINISH
|
|
|
|
async def run(self, controller: 'AgentController') -> 'Observation':
|
|
raise NotImplementedError
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return "All done! What's next on the agenda?"
|