Skip to content

Commit

Permalink
[Hot fix]Fix bug when dialog agent self.memory is None (modelscope#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
garyzhang99 authored Apr 16, 2024
1 parent 2eb7892 commit f94560b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/agentscope/agents/dialog_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(
"will be removed in the future.",
)

# TODO change typing from dict to MSG
def reply(self, x: dict = None) -> dict:
"""Reply function of the agent. Processes the input data,
generates a prompt using the current dialogue memory and system
Expand All @@ -78,7 +79,9 @@ def reply(self, x: dict = None) -> dict:
# prepare prompt
prompt = self.model.format(
Msg("system", self.sys_prompt, role="system"),
self.memory and self.memory.get_memory(), # type: ignore[arg-type]
self.memory
and self.memory.get_memory()
or x, # type: ignore[arg-type]
)

# call llm and generate response
Expand Down
5 changes: 4 additions & 1 deletion src/agentscope/agents/dict_dialog_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(
"will be removed in the future.",
)

# TODO change typing from dict to MSG
def reply(self, x: dict = None) -> dict:
"""Reply function of the agent.
Processes the input data, generates a prompt using the current
Expand Down Expand Up @@ -150,7 +151,9 @@ def reply(self, x: dict = None) -> dict:
# prepare prompt
prompt = self.model.format(
Msg("system", self.sys_prompt, role="system"),
self.memory and self.memory.get_memory(), # type: ignore[arg-type]
self.memory
and self.memory.get_memory()
or x, # type: ignore[arg-type]
)

# call llm
Expand Down

0 comments on commit f94560b

Please sign in to comment.