From 05b0ca4d47d96480ca8111520ec05f4e35e119fd Mon Sep 17 00:00:00 2001 From: DavdGao Date: Mon, 4 Nov 2024 16:46:04 +0800 Subject: [PATCH] Fix typos. --- src/agentscope/service/__init__.py | 6 ++++-- src/agentscope/tokens.py | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/agentscope/service/__init__.py b/src/agentscope/service/__init__.py index 472379d6c..6d2fd1342 100644 --- a/src/agentscope/service/__init__.py +++ b/src/agentscope/service/__init__.py @@ -66,8 +66,10 @@ def get_help() -> None: """Get help message.""" - tools = "\n - ".join(__all__) - help_msg = f"The following service are available:\n{tools}" + + help_msg = "\n - ".join( + ["The following services are available:"] + __all__[4:], + ) logger.info(help_msg) diff --git a/src/agentscope/tokens.py b/src/agentscope/tokens.py index cd172b42a..8375584b9 100644 --- a/src/agentscope/tokens.py +++ b/src/agentscope/tokens.py @@ -19,7 +19,7 @@ def count(model_name: str, messages: list[dict[str, str]]) -> int: model_name (`str`): The name of the model. messages (`list[dict[str, str]]`): - The list of messages, each message is a dict with the key 'text'. + A list of dictionaries. """ # Type checking if not isinstance(model_name, str): @@ -187,7 +187,7 @@ def count_openai_tokens( # pylint: disable=too-many-branches f"model {model_name}.", ) - num_tokens = 0 + num_tokens = 3 # every reply is primed with <|start|>assistant<|message|> for message in messages: num_tokens += tokens_per_message for key, value in message.items(): @@ -209,7 +209,6 @@ def count_openai_tokens( # pylint: disable=too-many-branches if key == "name": num_tokens += tokens_per_name - num_tokens += 3 # every reply is primed with <|start|>assistant<|message|> return num_tokens