From 33ac8c51092611f1ea61e18caa87362dd062c77f Mon Sep 17 00:00:00 2001 From: garylin2099 Date: Thu, 5 Sep 2024 10:42:04 +0800 Subject: [PATCH 1/4] increase mem window --- metagpt/roles/di/role_zero.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index f0df0aa4b..da26796d5 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -83,7 +83,7 @@ class RoleZero(Role): # Others command_rsp: str = "" # the raw string containing the commands commands: list[dict] = [] # commands to be executed - memory_k: int = 100 # number of memories (messages) to use as historical context + memory_k: int = 200 # number of memories (messages) to use as historical context use_fixed_sop: bool = False requirements_constraints: str = "" # the constraints in user requirements use_summary: bool = True # whether to summarize at the end From 42544806bd85cbfea1f8d677eb7e2c6e8633dd8e Mon Sep 17 00:00:00 2001 From: garylin2099 Date: Thu, 5 Sep 2024 19:16:39 +0800 Subject: [PATCH 2/4] revert sweagent to use bash --- metagpt/roles/di/swe_agent.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/metagpt/roles/di/swe_agent.py b/metagpt/roles/di/swe_agent.py index f147e80f3..d54c9dd44 100644 --- a/metagpt/roles/di/swe_agent.py +++ b/metagpt/roles/di/swe_agent.py @@ -11,7 +11,7 @@ from metagpt.prompts.di.swe_agent import ( from metagpt.roles.di.role_zero import RoleZero from metagpt.schema import Message from metagpt.tools.libs.git import git_create_pull -from metagpt.tools.libs.terminal import Terminal +from metagpt.tools.libs.terminal import Bash class SWEAgent(RoleZero): @@ -19,8 +19,13 @@ class SWEAgent(RoleZero): profile: str = "Issue Solver" goal: str = "Resolve GitHub issue or bug in any existing codebase" _instruction: str = NEXT_STEP_TEMPLATE - tools: list[str] = ["Browser:goto,scroll", "RoleZero", "git_create_pull", "Editor", "Terminal"] - terminal: Terminal = Field(default_factory=Terminal, exclude=True) + tools: list[str] = [ + "Bash", + "Browser:goto,scroll", + "RoleZero", + "git_create_pull", + ] + terminal: Bash = Field(default_factory=Bash, exclude=True) output_diff: str = "" max_react_loop: int = 40 run_eval: bool = False @@ -33,6 +38,7 @@ class SWEAgent(RoleZero): def _update_tool_execution(self): self.tool_execution_map.update( { + "Bash.run": self.terminal.run, "git_create_pull": git_create_pull, } ) From e9d7556a0e5b2b7f543e1e50d133be3fc8befc0e Mon Sep 17 00:00:00 2001 From: garylin2099 Date: Thu, 5 Sep 2024 19:35:35 +0800 Subject: [PATCH 3/4] add current time for search qa --- metagpt/actions/analyze_requirements.py | 2 +- metagpt/actions/research.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/metagpt/actions/analyze_requirements.py b/metagpt/actions/analyze_requirements.py index d81da3e14..86088d824 100644 --- a/metagpt/actions/analyze_requirements.py +++ b/metagpt/actions/analyze_requirements.py @@ -48,7 +48,7 @@ INSTRUCTIONS = """ You must output in the same language as the Requirements. First, This language should be consistent with the language used in the requirement description. determine the natural language you must respond in. If the requirements specify a special language, follow those instructions. The default language for responses is English. Second, extract the restrictions in the requirements, specifically the steps. Do not include detailed demand descriptions; focus only on the restrictions. -Third, if the requirements is a software development, extract the program language. If If no specific programming language is required, Use HTML (*.html), CSS (*.css), and JavaScript (*.js) +Third, if the requirements is a software development, extract the program language. If no specific programming language is required, Use HTML (*.html), CSS (*.css), and JavaScript (*.js) Note: 1. if there is not restrictions, requirements_restrictions must be "" diff --git a/metagpt/actions/research.py b/metagpt/actions/research.py index 98edfddb0..91a2e7090 100644 --- a/metagpt/actions/research.py +++ b/metagpt/actions/research.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio +from datetime import datetime from typing import Any, Callable, Coroutine, Optional, Union from pydantic import TypeAdapter, model_validator @@ -43,7 +44,9 @@ COLLECT_AND_RANKURLS_PROMPT = """### Topic {results} ### Requirements -Please remove irrelevant search results that are not related to the query or topic. Then, sort the remaining search results \ +Please remove irrelevant search results that are not related to the query or topic. +If the query is time-sensitive or specifies a certain time frame, please also remove search results that are outdated or outside the specified time frame. Notice that the current time is {time_stamp}. +Then, sort the remaining search results based on the link credibility. If two results have equal credibility, prioritize them based on the relevance. Provide the ranked results' indices in JSON format, like [0, 1, 3, 4, ...], without including other words. """ @@ -165,7 +168,8 @@ class CollectLinks(Action): max_results = max_num_results or max(num_results * 2, 6) results = await self._search_urls(query, max_results=max_results) _results = "\n".join(f"{i}: {j}" for i, j in zip(range(max_results), results)) - prompt = COLLECT_AND_RANKURLS_PROMPT.format(topic=topic, query=query, results=_results) + time_stamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + prompt = COLLECT_AND_RANKURLS_PROMPT.format(topic=topic, query=query, results=_results, time_stamp=time_stamp) logger.debug(prompt) indices = await self._aask(prompt) try: From 3f22d9e162d08a5172dbaacf7daa53ec36e82403 Mon Sep 17 00:00:00 2001 From: garylin2099 Date: Thu, 5 Sep 2024 19:37:56 +0800 Subject: [PATCH 4/4] format --- metagpt/actions/research.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/metagpt/actions/research.py b/metagpt/actions/research.py index 91a2e7090..99f72b076 100644 --- a/metagpt/actions/research.py +++ b/metagpt/actions/research.py @@ -46,9 +46,8 @@ COLLECT_AND_RANKURLS_PROMPT = """### Topic ### Requirements Please remove irrelevant search results that are not related to the query or topic. If the query is time-sensitive or specifies a certain time frame, please also remove search results that are outdated or outside the specified time frame. Notice that the current time is {time_stamp}. -Then, sort the remaining search results -based on the link credibility. If two results have equal credibility, prioritize them based on the relevance. Provide the -ranked results' indices in JSON format, like [0, 1, 3, 4, ...], without including other words. +Then, sort the remaining search results based on the link credibility. If two results have equal credibility, prioritize them based on the relevance. +Provide the ranked results' indices in JSON format, like [0, 1, 3, 4, ...], without including other words. """ WEB_BROWSE_AND_SUMMARIZE_PROMPT = """### Requirements