fix: address OpenAI compliance audit findings (streamed usage, request-id, docs)#19
Closed
Abhinavexist wants to merge 1 commit into
Closed
fix: address OpenAI compliance audit findings (streamed usage, request-id, docs)#19Abhinavexist wants to merge 1 commit into
Abhinavexist wants to merge 1 commit into
Conversation
- Streamed usage was dropped: _State never read chunk.usage (the usage chunk has empty choices, so accumulate returned before reading it). Capture chunk.usage + system_fingerprint and surface them on get_final_completion(). (audit #2 - the real bug) - Carry the server's _request_id through to_interfaze so it survives the model_dump/model_validate round-trip. (audit #3) - Fix pyproject Repository URL (interfaze/interfaze-py -> InterfazeAI/interfaze-python). (audit appendix) - README 'Compatibility notes': .stream() yields chunks not events; content post-processing (json fence / <think>/<precontext> tags); inputs.* URL non-portability; the interfaze.openai escape hatch; tasks.* return raw results. (audit #1/#4/#5/#6 + task-return note) Regression tests in tests/test_compliance.py (usage sync+async, request_id).
Collaborator
Author
|
Closing — the Issue #1 ( |
Khurdhula-Harshavardhan
requested changes
Jul 20, 2026
Khurdhula-Harshavardhan
left a comment
Contributor
There was a problem hiding this comment.
please help resolve the following.
| self.model = chunk.model | ||
| if not self.created and chunk.created: | ||
| self.created = chunk.created | ||
| if chunk.usage: |
Contributor
There was a problem hiding this comment.
Rebase on main; this reverts #7 and re-breaks precontext.
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.
Addresses the findings from the OpenAI compliance audit (run against
mainv0.1.0). These are orthogonal to the other open PRs (#7–#18) — none of them touched these paths.Code fixes
usagedropped (the real bug)._State.accumulatereadid/model/created/delta/finish/tool_callsbut neverchunk.usage; worse, the usage chunk arrives with emptychoices, soaccumulatereturned before reaching any usage read. Now it captureschunk.usage(andsystem_fingerprint) before the choices check and surfaces them onget_final_completion(). Verified:stream_options={"include_usage": True}→final.usage.total_tokens == 226._request_idlost.to_interfazeround-trips throughmodel_dump()/model_validate(), which drops the openai-attached_request_id. Now carried onto the result. (Latent today — the API doesn't sendx-request-idyet — but no longer silently discarded.)pyprojectRepositorypointed at the non-existentinterfaze/interfaze-py; fixed toInterfazeAI/interfaze-python.Docs (README "Compatibility notes")
.stream()yields chunks, not events (unlike OpenAI's event-based.stream()); iteratechunk.choices[0].delta.<think>/<precontext>extraction), somessage.contentmay not be byte-identical to the wire.inputs.*accept https URLs (Interfaze-only); not portable to OpenAI/Azure..parse()/.with_raw_response/.with_streaming_responselive oninterfaze.openai.tasks.*return the extracted result (dict/list/str), not aChatCompletion.Notes
.stream()rename the audit floats (Python create() raises ValidationError on tool-call responses (strict precontext) #1) is a breaking API decision — documented rather than renamed; happy to rename if you'd prefer.build()'sid/finish_reasondefaults are kept (reasonable for a completed stream);logprobsaccumulation is moot since Interfaze returnsnull.tests/test_compliance.py(streamed usage sync+async, request-id). Suite: 27 passing;ruff+mypy --strictclean. (CI runs once ci: GitHub Actions CI/CD (lint, types, tests, multimodal + token/usage, secret scan) #17 landsci.ymlonmain; verified locally.)