How to return number of tokens used when executing flow as a function? #3352
-
I load a flow and use it as a function in code successfully. But I can't find guidelines on how to return the prompt and completion tokens count. I knew that I can checked it through tracing UI by just calling
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @teohsinyee , flow-as-a-function is designed to execute flow with minimal extra logic so does not support returning token count. If you need to get token count, you can use flow run instead. You can get token count in flow run's Here's example code for it: run = pf.run(flow=flow, data=data, stream=True)
print(run.properties["system_metrics"]) |
Beta Was this translation helpful? Give feedback.
Currently only file is supported for
data
parameter. We have an issue tracking support passing list of dicts indata
parameter: #3207