mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
fix summaries (#191)
This commit is contained in:
@@ -66,9 +66,6 @@ INITIAL_THOUGHTS = [
|
||||
]
|
||||
|
||||
|
||||
MAX_OUTPUT_LENGTH = 5000
|
||||
MAX_MONOLOGUE_LENGTH = 20000
|
||||
|
||||
class LangchainsAgent(Agent):
|
||||
_initialized = False
|
||||
|
||||
|
||||
@@ -26,8 +26,10 @@ class Monologue:
|
||||
def condense(self, llm):
|
||||
try:
|
||||
prompt = prompts.get_summarize_monologue_prompt(self.thoughts)
|
||||
response = llm.prompt(prompt)
|
||||
self.thoughts = prompts.parse_summary_response(response)
|
||||
messages = [{"content": prompt,"role": "user"}]
|
||||
resp = llm.completion(messages=messages)
|
||||
summary_resp = resp['choices'][0]['message']['content']
|
||||
self.thoughts = prompts.parse_summary_response(summary_resp)
|
||||
except Exception as e:
|
||||
# Consider logging the error here instead of or in addition to raising an exception
|
||||
raise RuntimeError(f"Error condensing thoughts: {e}")
|
||||
|
||||
@@ -22,6 +22,7 @@ from opendevin.action import (
|
||||
AgentRecallAction,
|
||||
AgentThinkAction,
|
||||
AgentFinishAction,
|
||||
AgentSummarizeAction,
|
||||
)
|
||||
from opendevin.observation import (
|
||||
CmdOutputObservation,
|
||||
@@ -36,6 +37,7 @@ ACTION_TYPE_TO_CLASS: Dict[str, Type[Action]] = {
|
||||
"write": FileWriteAction,
|
||||
"recall": AgentRecallAction,
|
||||
"think": AgentThinkAction,
|
||||
"summarize": AgentSummarizeAction,
|
||||
"finish": AgentFinishAction,
|
||||
}
|
||||
CLASS_TO_ACTION_TYPE: Dict[Type[Action], str] = {v: k for k, v in ACTION_TYPE_TO_CLASS.items()}
|
||||
|
||||
@@ -2,7 +2,7 @@ from .base import Action, NullAction
|
||||
from .bash import CmdRunAction, CmdKillAction
|
||||
from .browse import BrowseURLAction
|
||||
from .fileop import FileReadAction, FileWriteAction
|
||||
from .agent import AgentRecallAction, AgentThinkAction, AgentFinishAction, AgentEchoAction
|
||||
from .agent import AgentRecallAction, AgentThinkAction, AgentFinishAction, AgentEchoAction, AgentSummarizeAction
|
||||
|
||||
__all__ = [
|
||||
"Action",
|
||||
@@ -16,4 +16,5 @@ __all__ = [
|
||||
"AgentThinkAction",
|
||||
"AgentFinishAction",
|
||||
"AgentEchoAction",
|
||||
"AgentSummarizeAction",
|
||||
]
|
||||
|
||||
@@ -48,6 +48,13 @@ class AgentEchoAction(ExecutableAction):
|
||||
def message(self) -> str:
|
||||
return self.content
|
||||
|
||||
@dataclass
|
||||
class AgentSummarizeAction(NotExecutableAction):
|
||||
summary: str
|
||||
|
||||
@property
|
||||
def message(self) -> str:
|
||||
return self.summary
|
||||
|
||||
@dataclass
|
||||
class AgentFinishAction(NotExecutableAction):
|
||||
@@ -59,3 +66,4 @@ class AgentFinishAction(NotExecutableAction):
|
||||
@property
|
||||
def message(self) -> str:
|
||||
return "All done! What's next on the agenda?"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user