modelscope / agentscope

Start building LLM-empowered multi-agent applications in an easier way.
https://doc.agentscope.io/
Apache License 2.0
5.34k stars 328 forks source link

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

Closed DavdGao closed 3 weeks ago

DavdGao commented 1 month ago

Description

  1. Add a new tokens module in AgentScope to handle token related events
  2. Support to count tokens for OpenAI, DashScope, Gemini and HuggingFace models
  3. Support to register token counting functions

TODO

A more elegant way to register token counting functions for different models

Checklist

Please check the following items before code is ready to be reviewed.