Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wrap()intercepted every method namedcreateon a wrapped client and parsed the result as a Chat Completion or Message. So calls likeclient.responses.create(...)andclient.embeddings.create(...)raisedAttributeError(for example'Response' object has no attribute 'choices'). Now only the supported calls are traced, and every other method passes through untouched:chat.completions.createandbeta.chat.completions.createmessages.createandbeta.messages.createStreaming and non-streaming calls are both traced, sync and async. Async detection also unwraps SDK decorators: they hid the coroutine function, so some async calls were treated as sync.
Changes
src/scorecard_ai/lib/_wrap_llms_otel.py: route only the supported attribute paths to the tracing wrapper; everything else returns the client's own attribute; useinspect.unwrapwhen detecting async methods.src/scorecard_ai/lib/wrap_llms.py: the docstring lists the traced methods.tests/lib/test_wrap_llms.py: 98 offline cases covering pass-through (Responses, embeddings, raw and streaming response wrappers), tracing for each supported method, sync and async, streaming and not.Tracing the Responses API could be a follow-up.
Testing
.venv/bin/python -m pytest -q tests/lib/test_wrap_llms.py: 98 passed (the regression cases fail onmain).ruff check,ruff format --check, andpyrighton the touched files: passed.