Skip to content

Conversation

benkawecki
Copy link

@benkawecki benkawecki commented Sep 16, 2025

Description

This PR filters out attributes where the value is NOT_GIVEN form the llm_request_attributes dictionary. The type of NOT_GIVEN cannot be set as an attribute value which creates a warning message for users. Note this only occurs if a user directly sets the value to be NOT_GIVEN, it doesn't occur for default values.

This warning message is generated in opentelemetry.attributes here.

Example WARNING log:

WARNING  opentelemetry.attributes:__init__.py:111 Invalid type NotGiven for attribute 'top_p' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
This behavior can be confirmed by passing NOT_GIVEN directly into a completions.create function call:

from openai import OpenAI, NOT_GIVEN

client = OpenAI()
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "Say this is a test"}],
    model=llm_model_value,
    top_p=NOT_GIVEN,
)

I've added this test case into the unittest.

  • test_chat_completion_handles_not_given

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Sep 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: benkawecki / name: Ben Kawcki (36f4e87)

@benkawecki
Copy link
Author

Note to reviewers, I'm unsure what the best way to update the cassette / VCR configurations is. If you have guidance for that please let me know.

@benkawecki benkawecki force-pushed the fix/handle-not-given-inputs-to-completions branch from ac1b180 to ec6ce62 Compare September 16, 2025 15:57
…rumentation for chat.completions.create operations
@benkawecki benkawecki force-pushed the fix/handle-not-given-inputs-to-completions branch from ec6ce62 to 36f4e87 Compare September 16, 2025 16:09
@benkawecki benkawecki marked this pull request as ready for review September 16, 2025 16:09
@benkawecki benkawecki requested a review from a team as a code owner September 16, 2025 16:09
@benkawecki benkawecki changed the title Buffix: Remove llm_request_attributes of type NOT_GIVEN to avoid excessive warning messages.j;w Buffix: Remove llm_request_attributes of type NOT_GIVEN to avoid excessive warning messages. Sep 16, 2025
@xrmx xrmx changed the title Buffix: Remove llm_request_attributes of type NOT_GIVEN to avoid excessive warning messages. openai: Remove llm_request_attributes of type NOT_GIVEN to avoid excessive warning messages Sep 17, 2025
@xrmx
Copy link
Contributor

xrmx commented Sep 17, 2025

Note to reviewers, I'm unsure what the best way to update the cassette / VCR configurations is. If you have guidance for that please let me know.

You remove the cassette and it gets recreated when you run tests again

@benkawecki
Copy link
Author

Note to reviewers, I'm unsure what the best way to update the cassette / VCR configurations is. If you have guidance for that please let me know.

You remove the cassette and it gets recreated when you run tests again

Ack. I'll have to do this later tonight then since I need to be on a different machine to hit the openai api. If you have any other issues with the PR lmk and I can resolve them.


# filter out None values
return {k: v for k, v in attributes.items() if v is not None}
# filter out None values and NOT_GIVEN values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of explicitly defining this logic here, would it make more sense to create a function for this similar to - non_numerical_value_is_set ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants