Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support token counting for OpenAI, DashScope, Gemini and HuggingFace models #470

Merged
merged 9 commits into from
Nov 5, 2024
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"sphinx_rtd_theme",
"myst-parser",
"sphinxcontrib-mermaid",
# extra
"transformers",
]

extra_gradio_requires = [
Expand Down
1 change: 1 addition & 0 deletions src/agentscope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from . import exception
from . import parsers
from . import rag
from . import tokens

# objects or function
from .msghub import msghub
Expand Down
2 changes: 1 addition & 1 deletion src/agentscope/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
LEVEL_SAVE_MSG = "SAVE_MSG"

_DEFAULT_LOG_FORMAT = (
"<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{"
"<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{"
"level: <8}</level> | <cyan>{name}</cyan>:<cyan>{"
"function}</cyan>:<cyan>{line}</cyan> - <level>{"
"message}</level>"
Expand Down
2 changes: 1 addition & 1 deletion src/agentscope/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def format(
self,
*args: Union[Msg, Sequence[Msg]],
) -> Union[List[dict], str]:
"""Format the input string or dict into the format that the model
"""Format the input messages into the format that the model
API required."""
raise NotImplementedError(
f"Model Wrapper [{type(self).__name__}]"
Expand Down
3 changes: 2 additions & 1 deletion src/agentscope/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@

def get_help() -> None:
"""Get help message."""
help_msg = f"The following service are available:\n{__all__}"
tools = "\n - ".join(__all__)
DavdGao marked this conversation as resolved.
Show resolved Hide resolved
help_msg = f"The following service are available:\n{tools}"
logger.info(help_msg)


Expand Down
2 changes: 1 addition & 1 deletion src/agentscope/service/browser/web_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def action_type(
self._page.evaluate("element => element.focus()", web_ele)

# Type in the text
web_ele.type(text)
web_ele.type(str(text))
self._wait_for_load(
"Wait for finish typing",
"Finished",
Expand Down
Loading
Loading