researcher allow override system prompt

This commit is contained in:
paulaan 2023-12-09 12:57:54 +07:00
parent 4006edac04
commit c92793c27c

View file

@ -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