From c92793c27ceae28cdc0fba67c39648b5cb42cabd Mon Sep 17 00:00:00 2001 From: paulaan Date: Sat, 9 Dec 2023 12:57:54 +0700 Subject: [PATCH] researcher allow override system prompt --- metagpt/roles/researcher.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/metagpt/roles/researcher.py b/metagpt/roles/researcher.py index c5512121a..f954c60bb 100644 --- a/metagpt/roles/researcher.py +++ b/metagpt/roles/researcher.py @@ -46,7 +46,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) if isinstance(todo, CollectLinks): links = await todo.run(topic, 4, 4) ret = Message("", Report(topic=topic, links=links), role=self.profile, cause_by=type(todo)) @@ -64,6 +64,17 @@ class Researcher(Role): self._rc.memory.add(ret) return ret + def research_system_text(self, topic) -> 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