fix summaries (#191)

This commit is contained in:
Robert Brennan
2024-03-26 11:44:54 -04:00
committed by GitHub
parent 9e924ab4b1
commit 134cc2bc84
5 changed files with 16 additions and 6 deletions

View File

@@ -66,9 +66,6 @@ INITIAL_THOUGHTS = [
]
MAX_OUTPUT_LENGTH = 5000
MAX_MONOLOGUE_LENGTH = 20000
class LangchainsAgent(Agent):
_initialized = False

View File

@@ -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}")

View File

@@ -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()}

View File

@@ -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",
]

View File

@@ -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?"