xebia-functional / xef

Building applications with LLMs through composability, in Kotlin, Scala, ...

Home Page:https://xef.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

impl of computing a message's token count for providers other than OpenAI

Intex32 opened this issue · comments

commented

In LLM there is a function called tokensFromMessages. Current default implementation is using the models encoding (from ModelType) to compute the token count locally.

Problem: Afaik, the encoding is not made publicly available by Google. Thus we have to make an API call to GCP (https://cloud.google.com/vertex-ai/docs/generative-ai/get-token-count).

TODO: default implementation of tokensFromMessages has to be removed and replaced by provider specific implementations (for OpenAI based on encoding, and for GCP on external API call)

depends on #393
depends on #405