Find answers from the community

Updated 3 months ago

hi does anyone have token counting

hi, does anyone have token counting working for streaming? seems prompt and completion tokens are not tracked. in verbose counter logs it seems prompt and completion events are not raised
L
s
16 comments
Yea this is not implemented yet πŸ˜…

I think this could be possible by wrapping the generator to include calling the token counting callback once the generator is exhausted πŸ€”
ok just wanted to make sure, that it's not an easy one like that index_name vs class_name!
i'll try to implement
it's not a super high need right now so may not get to it right away
yea no worries! Sounds good
@Logan M if you have a chance take a quick peek at the agentchatresponse and source node question in kapa bot. if i'm correct (that it was dropped in a previous release), then i'll also work on adding that back
sorry, what's the issue? πŸ˜… There are still sources in the agent chat response, but the sources are formatted as ToolOutput objects (since there could be any number of tools)

If the tool was a query engine, you can access the raw_output which is the query engine response output

agent_response.sources[0].raw_output.source_nodes
there's also a few other attributes

tool_name
raw_input
content
yeah i found it. it' just easier if made available directly as source_nodes like response and streamingresponse
let me know what you think thanks
if it's not there from the query itself, then there isn't anything
left a comment!
(Also thanks for working to make this better πŸ™ )
of course glad to contribute. responded
Add a reply
Sign up and join the conversation on Discord