langserve icon indicating copy to clipboard operation
langserve copied to clipboard

include_callback_events=True doesn't work in stream / stream_log endpoint

Open JayAhn2 opened this issue 1 year ago • 5 comments

Hi!

I found that include_callback_events doesn't work in stream / stream_log.

I need to check token counts when I call stream / stream_log.

Is it intended?

Many thanks :)

JayAhn2 avatar Jan 09 '24 02:01 JayAhn2

Haven't gotten around to implementing it yet. Are you relying on RemoteRunnable for handling the callbacks?

Would sending the callbacks at the end of the stream work for your use case?

eyurtsev avatar Jan 09 '24 02:01 eyurtsev

@eyurtsev

Yes. I need to see callback_events at the end of the stream :)

It is required because my service only uses stream_log endpoint, and need to store token counts on each request.

JayAhn2 avatar Jan 09 '24 03:01 JayAhn2

it's end of stream vs. sending the callbacks in "real time" as they occur -- so they will be intermingled with event data. At the end shouldn't be too difficult to do.

End of stream shouldn't be too difficult to do, so i'll try to sequence that soonish

eyurtsev avatar Jan 09 '24 03:01 eyurtsev

@eyurtsev

IMHO, I guess real time callback isn't so meaningful, as callbacks are required for auditing the prompt and response for my case ;)

JayAhn2 avatar Jan 09 '24 03:01 JayAhn2

Hi @JayAhn2, I haven't picked up work on this yet

Quick question -- have you confirmed that you can get token counts when streaming with the model provider that you use?

I suspect that including callback events for streaming might not actually solve your use case as you'll need to run code client side to tokenize the response and count the tokens manually (even with callbacks included)

eyurtsev avatar Feb 02 '24 00:02 eyurtsev