Skip to content

Commit

Permalink
Support token counting for OpenAI, DashScope, Gemini and HuggingFace …
Browse files Browse the repository at this point in the history
…models (#470)
  • Loading branch information
DavdGao authored Nov 5, 2024
1 parent 9c01615 commit 1d0373b
Show file tree
Hide file tree
Showing 8 changed files with 536 additions and 4 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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
5 changes: 4 additions & 1 deletion src/agentscope/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@

def get_help() -> None:
"""Get help message."""
help_msg = f"The following service are available:\n{__all__}"

help_msg = "\n - ".join(
["The following services are available:"] + __all__[4:],
)
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

0 comments on commit 1d0373b

Please sign in to comment.