You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm using promptflow for trace collecting. When running the application it fails in collect_openai_tokens_for_parent_span method method with the error: "TypeError: unsupported operand type(s) for +: 'int' and 'dict'\n'}}], 'debugInfo': {'type': 'ScriptExecutionError', 'message': "Execution failure in 'rag_flow': (TypeError) unsupported operand type(s) for +: 'int' and 'dict'""
How To Reproduce the bug
from promptflow.tracing import start_trace
start_trace()
... code ...
Then from command line run: pf flow serve --source ./ --port 8080 --host localhost
at some point the failure happens
Running Information(please complete the following information):
Additional context
Issue explanation: The root cause is in this code :
merged_tokens = {
# When token count is None for some reason, we should default to 0.
key: (self._span_id_to_tokens[parent_span_id].get(key, 0) or 0) + (tokens.get(key, 0) or 0)
for key in set(self._span_id_to_tokens[parent_span_id]) | set(tokens)
}
this is because can be that "tokens" dictionary is not flat dictionary but could contain another dictionaries.
For example: {'completion_tokens': 112, 'prompt_tokens': 587, 'total_tokens': 699, 'completion_tokens_details': {'audio_tokens': 0, 'reasoning_tokens': 0, 'accepted_prediction_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}} . In this case tokens dictionary contains "completion_tokens_details and prompt_tokens_details which are dictionaries. However the code attempting 0 + dictionary, and this crash the code.
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm using promptflow for trace collecting. When running the application it fails in collect_openai_tokens_for_parent_span method method with the error: "TypeError: unsupported operand type(s) for +: 'int' and 'dict'\n'}}], 'debugInfo': {'type': 'ScriptExecutionError', 'message': "Execution failure in 'rag_flow': (TypeError) unsupported operand type(s) for +: 'int' and 'dict'""
How To Reproduce the bug
from promptflow.tracing import start_trace
start_trace()
... code ...
Then from command line run: pf flow serve --source ./ --port 8080 --host localhost
at some point the failure happens
Running Information(please complete the following information):
{
"promptflow": "1.16.2",
"promptflow-azure": "1.16.1",
"promptflow-core": "1.16.2",
"promptflow-devkit": "1.16.2",
"promptflow-tracing": "1.16.2"
}
OS:
ProductName: macOS
ProductVersion: 15.2
BuildVersion: 24C101
Python 3.11.11
Additional context
Issue explanation: The root cause is in this code :
merged_tokens = {
# When token count is None for some reason, we should default to 0.
key: (self._span_id_to_tokens[parent_span_id].get(key, 0) or 0) + (tokens.get(key, 0) or 0)
for key in set(self._span_id_to_tokens[parent_span_id]) | set(tokens)
}
this is because can be that "tokens" dictionary is not flat dictionary but could contain another dictionaries.
For example: {'completion_tokens': 112, 'prompt_tokens': 587, 'total_tokens': 699, 'completion_tokens_details': {'audio_tokens': 0, 'reasoning_tokens': 0, 'accepted_prediction_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}} . In this case tokens dictionary contains "completion_tokens_details and prompt_tokens_details which are dictionaries. However the code attempting 0 + dictionary, and this crash the code.
The text was updated successfully, but these errors were encountered: