Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Getting unsupported operand type(s) for +: 'dict' and 'dict' when running chat-with-wikipedia flow #3834

Open
sgahlot opened this issue Oct 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@sgahlot
Copy link

sgahlot commented Oct 25, 2024

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:

  1. I used Open in GitHub Codespaces option to use the pre-built environment
  2. Run the examples/flows/chat/chat-with-wikipedia flow, using Run it with standard mode option
  3. 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"
  4. 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
Image
Image

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

@sgahlot sgahlot added the bug Something isn't working label Oct 25, 2024
@sgahlot
Copy link
Author

sgahlot commented Oct 25, 2024

I also tried setting the tracing to none thinking it won't go to _trace.py but that didn't make any difference. But when I set the
PF_DISABLE_TRACING environment variable to true (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.

@yeamusic21
Copy link

yeamusic21 commented Nov 13, 2024

Looks like I had the same, or at least a similar, issue. See #3850

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants