mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
feat: add metadata {"agent":xx} to assistant message
This commit is contained in:
parent
db34c6f458
commit
e37aa8e5bf
2 changed files with 4 additions and 1 deletions
|
|
@ -407,8 +407,10 @@ class Role(SerializationMixin, ContextMixin, BaseModel):
|
|||
)
|
||||
elif isinstance(response, Message):
|
||||
msg = response
|
||||
elif isinstance(response, AIMessage):
|
||||
msg = response.with_agent(self._setting)
|
||||
else:
|
||||
msg = AIMessage(content=response, cause_by=self.rc.todo, sent_from=self)
|
||||
msg = AIMessage(content=response, cause_by=self.rc.todo, sent_from=self).with_agent(self._setting)
|
||||
if self.enable_memory:
|
||||
self.rc.memory.add(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -378,6 +378,7 @@ class AIMessage(Message):
|
|||
|
||||
def with_agent(self, name: str):
|
||||
self.add_metadata(key=AGENT, value=name)
|
||||
return self
|
||||
|
||||
@property
|
||||
def agent(self) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue