Skip to content

feat: instrument the openai responses API#1493

Closed
satyadevai wants to merge 3 commits intoArize-ai:mainfrom
satyadevai:satya/openai-responses-instrumentation
Closed

feat: instrument the openai responses API#1493
satyadevai wants to merge 3 commits intoArize-ai:mainfrom
satyadevai:satya/openai-responses-instrumentation

Conversation

@satyadevai
Copy link
Copy Markdown
Collaborator

New Changes:

  • Added support for tracing and instrumenting OpenAI responses using the new Responses API integration.
  • Included sample code and usage examples to simplify testing and validation of the integration.
  • Added unit tests to ensure functionality and maintain reliability of the newly added features.

Resolves #1351

@satyadevai satyadevai requested a review from a team as a code owner April 4, 2025 16:59
@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Apr 4, 2025
@satyadevai satyadevai requested a review from Copilot April 4, 2025 17:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 14 out of 16 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • python/instrumentation/openinference-instrumentation-openai/examples/requirements.txt: Language not supported
  • python/instrumentation/openinference-instrumentation-openai/test-requirements.txt: Language not supported
Comments suppressed due to low confidence (1)

python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_response_accumulator.py:64

  • [nitpick] Consider renaming 'chat_completion_type' to 'responses_type' for clarity, as it represents a Response type in the context of responses.
chat_completion_type: Type["Response"],

@satyadevai satyadevai requested a review from Copilot April 4, 2025 17:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 14 out of 16 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • python/instrumentation/openinference-instrumentation-openai/examples/requirements.txt: Language not supported
  • python/instrumentation/openinference-instrumentation-openai/test-requirements.txt: Language not supported
Comments suppressed due to low confidence (3)

python/instrumentation/openinference-instrumentation-openai/tests/openinference/instrumentation/openai/test_instrumentor.py:541

  • The delta field value '{' may result in malformed JSON parsing; please verify if this is intentional or adjust the mock data to represent a properly concatenated delta message.
b'event: response.function_call_arguments.delta\ndata: {"type":"response.function_call_arguments.delta","item_id":"call_caea3f3962f34170b06d77f8f69da8e1","output_index":0,"delta":"{"}\n\n'

python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_utils.py:40

  • [nitpick] Consider providing more descriptive documentation or renaming the 'cast_to' parameter to better clarify its purpose in transforming the input object.
def _io_value_and_type(obj: Any, cast_to: Optional[type] = None) -> _ValueAndType:

python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_response_accumulator.py:75

  • Consider using isinstance() for type checks instead of comparing the name string to improve type safety and handle subclassing properly.
if type(chunk).__name__ == "ResponseCompletedEvent":

@satyadevai satyadevai requested a review from Copilot April 4, 2025 18:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 16 out of 18 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • python/instrumentation/openinference-instrumentation-openai/examples/requirements.txt: Language not supported
  • python/instrumentation/openinference-instrumentation-openai/test-requirements.txt: Language not supported
Comments suppressed due to low confidence (2)

python/instrumentation/openinference-instrumentation-openai/tests/openinference/instrumentation/openai/test_instrumentor.py:541

  • The delta JSON fragment appears incomplete, with the delta value being just an opening brace. Please verify that the split fragments (lines 541–542) will be concatenated correctly in the stream so that the overall JSON is valid.
b'event: response.function_call_arguments.delta\ndata: {"type":"response.function_call_arguments.delta","item_id":"call_caea3f3962f34170b06d77f8f69da8e1","output_index":0,"delta":"{"}\n\n',  # noqa: E501

python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_response_accumulator.py:75

  • Instead of comparing the type name as a string, consider using isinstance() with the actual ResponseCompletedEvent type (if available) to improve robustness and maintainability.
if type(chunk).__name__ == "ResponseCompletedEvent":

@Jgilhuly Jgilhuly moved this to In Review in Instrumentation Apr 8, 2025
@caroger caroger requested a review from RogerHYang April 10, 2025 16:54
@RogerHYang
Copy link
Copy Markdown
Contributor

transferred to #1521

@RogerHYang RogerHYang closed this Apr 16, 2025
@github-project-automation github-project-automation Bot moved this from In Review to Done in Instrumentation Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[feature request] instrument the openai responses API

4 participants