promptflow: [BUG] Getting unsupported operand type(s) for +: 'dict' and 'dict' when running chat-with-wikipedia flow
Describe the bug
When running chat-with-wikipedia flow, I’m encountering the following error:
...
File "/usr/local/lib/python3.9/site-packages/promptflow/tracing/_trace.py", line 145, in <dictcomp>
key: (self._span_id_to_tokens[parent_span_id].get(key, 0) or 0) + (tokens.get(key, 0) or 0)
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
How To Reproduce the bug Steps to reproduce the behavior, how frequent can you experience the bug:
- I used
Open in GitHub Codespacesoption to use the pre-built environment - Run the
examples/flows/chat/chat-with-wikipediaflow, usingRun it with standard modeoption - The command I see in the terminal is:
/usr/local/bin/python3 -m promptflow._cli._pf.entry flow test --flow /workspaces/promptflow/examples/flows/chat/chat-with-wikipedia --user-agent "prompt-flow-extension/1.20.2 (linux; x64) VSCode/1.94.2" - The following error comes every single time this flow is run
2024-10-25 14:55:25 +0000 17101 execution.flow INFO Executing node augmented_chat. node run id: edeaf1be-c107-4555-851f-38d5706e7a30_augmented_chat_0
WARNING:opentelemetry.attributes:Invalid type dict for attribute '__computed__.cumulative_token_count.completion' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
WARNING:opentelemetry.attributes:Invalid type dict for attribute '__computed__.cumulative_token_count.prompt' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
WARNING:opentelemetry.attributes:Invalid type dict for attribute 'llm.usage.completion_tokens_details' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
WARNING:opentelemetry.attributes:Invalid type dict for attribute 'llm.usage.prompt_tokens_details' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
WARNING:opentelemetry.attributes:Invalid type dict for attribute '__computed__.cumulative_token_count.completion' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
WARNING:opentelemetry.attributes:Invalid type dict for attribute '__computed__.cumulative_token_count.prompt' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
2024-10-25 14:55:26 +0000 17101 execution ERROR Node augmented_chat in line 0 failed. Exception: Execution failure in 'augmented_chat': (TypeError) unsupported operand type(s) for +: 'dict' and 'dict'.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/promptflow/_core/flow_execution_context.py", line 182, in _invoke_tool_inner
return f(**kwargs)
File "/usr/local/lib/python3.9/site-packages/promptflow/executor/flow_executor.py", line 1344, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/promptflow/tracing/_trace.py", line 562, in wrapped
token_collector.collect_openai_tokens_for_parent_span(span)
File "/usr/local/lib/python3.9/site-packages/promptflow/tracing/_trace.py", line 143, in collect_openai_tokens_for_parent_span
merged_tokens = {
File "/usr/local/lib/python3.9/site-packages/promptflow/tracing/_trace.py", line 145, in <dictcomp>
key: (self._span_id_to_tokens[parent_span_id].get(key, 0) or 0) + (tokens.get(key, 0) or 0)
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
Expected behavior I am expecting the flow to run without any errors
Screenshots
I’m attaching two screenshots to show the error
Running Information(please complete the following information):
- Promptflow Package Version using
pf -v: [e.g. 0.0.102309906]
{
"promptflow": "1.16.1",
"promptflow-azure": "1.16.1",
"promptflow-core": "1.16.1",
"promptflow-devkit": "1.16.1",
"promptflow-tracing": "1.16.1"
}
Executable '/usr/local/bin/python3.9'
Python (Linux) 3.9.20 (main, Oct 19 2024, 01:00:05)
[GCC 10.2.1 20210110]
- Operating System: Linux (GitHub Codespaces) -
Debian GNU/Linux 11 (bullseye) - Python Version using
python --version:Python 3.9.20
Additional context This is my first time using GitHub Codespaces as well as Prompt flow, so if there’s some additional initialization/config that I had to run, please let me know
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 18
https://microsoft.github.io/promptflow/reference/changelog/promptflow-tracing.html shows that this issue was fixed in
Where is this release available? Looks like it is not yet published.
in
flow.dag.yamlat the end trythe workaround of disabled tracing work for me. but is there a work around to still use trace? as I am using trace for my evaluation workflow.
I also tried setting the tracing to
nonethinking it won’t go to _trace.py but that didn’t make any difference. But when I set thePF_DISABLE_TRACINGenvironment variable totrue(in the same terminal) and re-ran the flow command, I didn’t get this error as the tracing code didn’t run in that case.