Repository navigation
Conversation
parse() returned a plain OpenAI ParsedChatCompletion, so Interfaze extras (precontext, vcache, reasoning, debug) came back untyped and response.precontext[0].result raised AttributeError. Add InterfazeParsedChatCompletion and convert the parse() result (sync + async), keeping message.parsed intact.
This branch has not been deployed
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.
Problem
interfaze.chat.completions.parse(...)returns a plain OpenAIParsedChatCompletion, so the Interfaze extras come back untyped:response.precontextis a list of plaindicts, and the documented patternresponse.precontext[0].resultraisesAttributeError: 'dict' object has no attribute 'result'whenever precontext is present (e.g. any image/OCR request).create()is fine because it goes throughto_interfaze()->InterfazeChatCompletion.The pattern is used in 26 docs snippets on interfaze.ai and 4 agent skills, so all of them fail on
.parse(today.Root cause
Completions.parse/AsyncCompletions.parseinsrc/interfaze/_chat.pyjustreturn self._client.chat.completions.parse(...). The extras are only present as untyped pydanticmodel_extra. The old comment aboveparse()documented this as intended.Fix
InterfazeParsedChatCompletion(ParsedChatCompletion[ContentType])in_types.pywith the same extras asInterfazeChatCompletion(precontext: Optional[List[Precontext]],reasoning,vcache,debug). Exported frominterfaze.to_interfaze_parsed()in_chat.py(counterpart ofto_interfaze). It does not usemodel_dump()(that would flattenmessage.parsedback into a dict); it re-validates from the existing field values plusmodel_extra, sochoices[0].message.parsedis the same model instance as before._request_idis carried over, liketo_interfaze.parse()return it; comment aboveparse()updated; one README sentence added. No CHANGELOG exists in the repo.ParsedChatCompletion[Any]->InterfazeParsedChatCompletion[Any], a subclass), so it is backwards compatible.Verification
Unit tests (tests/test_compliance.py, respx mocks): sync + async parse with precontext present (typed
Precontext,.result,vcache,reasoning,.parsedis the pydantic model), absent (defaultsNone/False,.parsedworks), mixed raw tool-call precontext entries,_request_idcarry-over.ruff check(ruff 0.17.5, noselectin pyproject so default rules): main already has 192 findings (mostly UP006/UP035/UP045 from the repo'sOptional/List/Dictstyle); this branch has 197, the +5 are the same classes in the new code, written to match existing style. Nothing in E/F/B/I is new.Live check against api.interfaze.ai (branch installed editable in own venv,
x-interfaze-bypass-cache: true), ID image + pydanticIDCard:Risks & follow-ups
ParsedChatCompletion;isinstancechecks and attribute access keep working. Code that relied onprecontextitems being dicts (pc[0]["result"]) will break —Precontextis a pydantic model; use.result/.model_dump(). This is the documented/intended access pattern.with_raw_response.parse(...)is still the untyped OpenAI path (out of scope).