feat: merge geekan:dev

This commit is contained in:
莘权 马 2023-12-24 12:49:08 +08:00
commit ad639b9906
5 changed files with 14 additions and 13 deletions

View file

@ -181,6 +181,7 @@ class WebBrowseAndSummarize(Action):
desc: str = "Explore the web and provide summaries of articles and webpages."
browse_func: Union[Callable[[list[str]], None], None] = None
web_browser_engine: WebBrowserEngine = WebBrowserEngine(
options={}, # FIXME: REMOVE options?
engine=WebBrowserEngineType.CUSTOM if browse_func else None,
run_func=browse_func,
)

View file

@ -123,7 +123,7 @@ class WritePRD(Action):
# logger.info(rsp)
project_name = CONFIG.project_name if CONFIG.project_name else ""
context = CONTEXT_TEMPLATE.format(requirements=requirements, project_name=project_name)
node = await WRITE_PRD_NODE.fill(context=context, llm=self.llm, schema=schema)
node = await WRITE_PRD_NODE.fill(context=context, llm=self.llm) # schema=schema
await self._rename_workspace(node)
return node

View file

@ -28,7 +28,7 @@ from tenacity import (
)
from metagpt.config import CONFIG, Config, LLMProviderEnum
from metagpt.const import DEFAULT_MAX_TOKENS
from metagpt.const import DEFAULT_MAX_TOKENS, DEFAULT_TOKEN_SIZE
from metagpt.logs import logger
from metagpt.provider.base_gpt_api import BaseGPTAPI
from metagpt.provider.constant import GENERAL_FUNCTION_SCHEMA, GENERAL_TOOL_CHOICE

View file

@ -78,9 +78,8 @@ class Engineer(Role):
n_borg: int = 1
use_code_review: bool = False
code_todos: list = []
summarize_todos = []
todo_desc: str = any_to_name(WriteCode)
summarize_todos: list = []
next_todo_action: str = ""
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
@ -89,6 +88,7 @@ class Engineer(Role):
self._watch([WriteTasks, SummarizeCode, WriteCode, WriteCodeReview, FixBug])
self.code_todos = []
self.summarize_todos = []
self.next_todo_action = any_to_name(WriteCode)
@staticmethod
def _parse_tasks(task_msg: Document) -> list[str]:
@ -132,10 +132,10 @@ class Engineer(Role):
if self._rc.todo is None:
return None
if isinstance(self._rc.todo, WriteCode):
self.todo_desc = any_to_name(SummarizeCode)
self.next_todo_action = any_to_name(SummarizeCode)
return await self._act_write_code()
if isinstance(self._rc.todo, SummarizeCode):
self.todo_desc = any_to_name(WriteCode)
self.next_todo_action = any_to_name(WriteCode)
return await self._act_summarize()
return None
@ -311,4 +311,4 @@ class Engineer(Role):
@property
def todo(self) -> str:
"""AgentStore uses this attribute to display to the user what actions the current role should take."""
return self.todo_desc
return self.next_todo_action

View file

@ -29,14 +29,14 @@ class ProductManager(Role):
profile: str = "Product Manager"
goal: str = "efficiently create a successful product that meets market demands and user expectations"
constraints: str = "utilize the same language as the user requirements for seamless communication"
todo_desc: str = any_to_name(PrepareDocuments)
todo_action: str = ""
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self._init_actions([PrepareDocuments, WritePRD])
self._watch([UserRequirement, PrepareDocuments])
self.todo_action = any_to_name(PrepareDocuments)
async def _think(self) -> bool:
"""Decide what to do"""
@ -44,13 +44,13 @@ class ProductManager(Role):
self._set_state(1)
else:
self._set_state(0)
self.todo_desc = any_to_name(WritePRD)
self.todo_action = any_to_name(WritePRD)
return bool(self._rc.todo)
async def _observe(self, ignore_memory=False) -> int:
return await super(ProductManager, self)._observe(ignore_memory=True)
return await super()._observe(ignore_memory=True)
@property
def todo(self) -> str:
"""AgentStore uses this attribute to display to the user what actions the current role should take."""
return self.todo_desc
return self.todo_action