langchain icon indicating copy to clipboard operation
langchain copied to clipboard

count tokens used in chain

Open hwchase17 opened this issue 2 years ago • 3 comments

should be doable with callbacks

hwchase17 avatar Jan 07 '23 20:01 hwchase17

@hwchase17 , is this related to calculating token_usage in chain?

dheerajiiitv avatar Jan 19 '23 10:01 dheerajiiitv

Yes, it would be idea to calculate token_usage for every chain/agent and add it to the output.

cyberandy avatar Jan 19 '23 16:01 cyberandy

It should be doable with callbacks to the output

Mehuldobriyal123 avatar Jan 21 '23 03:01 Mehuldobriyal123

done! https://langchain.readthedocs.io/en/latest/modules/llms/examples/token_usage_tracking.html

hwchase17 avatar Jan 24 '23 08:01 hwchase17