mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-03 04:42:38 +02:00
Merge pull request #543 from igot-ai/feat/reasearch-override-sys-prompt
[CHORE] Research Role allow override sys prompt
This commit is contained in:
commit
44ed73df7d
1 changed files with 14 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ import asyncio
|
|||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from metagpt.actions import CollectLinks, ConductResearch, WebBrowseAndSummarize
|
||||
from metagpt.actions import Action, CollectLinks, ConductResearch, WebBrowseAndSummarize
|
||||
from metagpt.actions.research import get_research_system_text
|
||||
from metagpt.const import RESEARCH_PATH
|
||||
from metagpt.logs import logger
|
||||
|
|
@ -51,7 +51,7 @@ class Researcher(Role):
|
|||
else:
|
||||
topic = msg.content
|
||||
|
||||
research_system_text = get_research_system_text(topic, self.language)
|
||||
research_system_text = self.research_system_text(topic, todo)
|
||||
if isinstance(todo, CollectLinks):
|
||||
links = await todo.run(topic, 4, 4)
|
||||
ret = Message("", Report(topic=topic, links=links), role=self.profile, cause_by=todo)
|
||||
|
|
@ -69,6 +69,18 @@ class Researcher(Role):
|
|||
self._rc.memory.add(ret)
|
||||
return ret
|
||||
|
||||
def research_system_text(self, topic, current_task: Action) -> str:
|
||||
""" BACKWARD compatible
|
||||
This allows sub-class able to define its own system prompt based on topic.
|
||||
return the previous implementation to have backward compatible
|
||||
Args:
|
||||
topic:
|
||||
language:
|
||||
|
||||
Returns: str
|
||||
"""
|
||||
return get_research_system_text(topic, self.language)
|
||||
|
||||
async def react(self) -> Message:
|
||||
msg = await super().react()
|
||||
report = msg.instruct_content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue