diff --git a/src/agentscope/_version.py b/src/agentscope/_version.py index 15bac20c90..2a3386b3ef 100644 --- a/src/agentscope/_version.py +++ b/src/agentscope/_version.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- """The version of agentscope.""" -__version__ = "1.0.19.post1" +__version__ = "1.0.20" diff --git a/src/agentscope/formatter/_deepseek_formatter.py b/src/agentscope/formatter/_deepseek_formatter.py index f9dce39536..5a3d397be6 100644 --- a/src/agentscope/formatter/_deepseek_formatter.py +++ b/src/agentscope/formatter/_deepseek_formatter.py @@ -105,7 +105,7 @@ async def _format( msg_deepseek = { "role": msg.role, - "content": content_msg or None, + "content": content_msg or (None if tool_calls else ""), } if reasoning_msg: diff --git a/src/agentscope/formatter/_formatter_base.py b/src/agentscope/formatter/_formatter_base.py index 6abb05a99e..b75982315e 100644 --- a/src/agentscope/formatter/_formatter_base.py +++ b/src/agentscope/formatter/_formatter_base.py @@ -68,6 +68,9 @@ def convert_tool_result_to_string( second element is the corresponding block. """ + if output is None: + return "", [] + if isinstance(output, str): return output, [] diff --git a/src/agentscope/formatter/_truncated_formatter_base.py b/src/agentscope/formatter/_truncated_formatter_base.py index 86d42ad41e..4175181be1 100644 --- a/src/agentscope/formatter/_truncated_formatter_base.py +++ b/src/agentscope/formatter/_truncated_formatter_base.py @@ -2,7 +2,6 @@ """The truncated formatter base class, which allows to truncate the input messages.""" from abc import ABC -from copy import deepcopy from typing import ( Any, Tuple, @@ -66,7 +65,7 @@ async def format( # Check if the input messages are valid self.assert_list_of_msgs(msgs) - msgs = deepcopy(msgs) + msgs = list(msgs) while True: formatted_msgs = await self._format(msgs) diff --git a/src/agentscope/model/_anthropic_model.py b/src/agentscope/model/_anthropic_model.py index 8c9e9d1deb..9c4e607c80 100644 --- a/src/agentscope/model/_anthropic_model.py +++ b/src/agentscope/model/_anthropic_model.py @@ -461,10 +461,13 @@ async def _parse_anthropic_stream_completion_response( # (e.g., DashScope), the input tokens are contained in # events where event.type == "message_delta", so we add # this step to extract the value. - final_input_tokens = getattr( - event.usage, - "input_tokens", - 0, + final_input_tokens = ( + getattr( + event.usage, + "input_tokens", + 0, + ) + or 0 ) if final_input_tokens > usage.input_tokens: usage.input_tokens = final_input_tokens