Robert Brennan 2 gadi atpakaļ
vecāks
revīzija
134cc2bc84

+ 0 - 3
agenthub/langchains_agent/__init__.py

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

+ 4 - 2
agenthub/langchains_agent/utils/monologue.py

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

+ 2 - 0
agenthub/langchains_agent/utils/prompts.py

@@ -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 - 1
opendevin/action/__init__.py

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

+ 8 - 0
opendevin/action/agent.py

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