Uh oh!
There was an error while loading. Please reload this page.
feat: ChatInterfaze — in-repo LangChain chat model (#5) - #12
Merged
Conversation
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.
Uh oh!
There was an error while loading. Please reload this page.
Khurdhula-Harshavardhan
left a comment
Contributor
There was a problem hiding this comment.
please help resolve the following.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Add an in-repo langchain-openai chat model (optional interfaze[langchain]
extra) that fixes the ChatOpenAI(base_url=...) fallback gaps:
- surfaces Interfaze's custom response fields (precontext/reasoning/vcache)
on response_metadata + additional_kwargs (non-stream and stream paths)
- injects request-side precontext via extra_body
- accepts {"type":"video",...} content blocks by rewriting them to a file
part before the stock converter rejects them
- strips inline <think>/<precontext> tags from content
Not imported from the package root, so the core SDK stays langchain-free.
Ships as an optional extra with mocked unit tests.…E (review #12) - _stream/_astream now filter <think>/<precontext> statefully across chunk boundaries (_SideChannelFilter) and recover reasoning/precontext from the full accumulation at stream-end, instead of the per-chunk strip that dropped split tags. - _convert_video_block forwards mime_type as file.format (else server sees octet-stream).
Abhinavexistforce-pushed
the
feat/langchain-chatinterfaze
branch
from
July 21, 2026 00:57
65bab7c to
7f22448Compare…ow_subclassing_any + warn_return_any) (review #12)
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 freeto 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.
Addresse #5
An optional
interfaze[langchain]extra shippingChatInterfaze(subclass oflangchain_openai.ChatOpenAI, targeting langchain-openai ≥1.3.5). It fixes the gaps the issue documents in the stockChatOpenAI(base_url=...)fallback:precontext/reasoning/vcache) silently dropped_create_chat_result+_convert_chunk_to_generation_chunkto copy them ontoresponse_metadata+additional_kwargs(non-stream and stream)precontextonly via rawextra_bodyprecontextfield injected intoextra_bodyin_get_request_payload(merges, doesn't clobber a caller'sextra_body){"type":"video",...}blocks raiseValueErrorfilepart before the stock converter sees them<think>/<precontext>tags not strippedstrip_side_channels(only when a tag is actually present, to preserve chunk whitespace)Defaults
base_url/modelto Interfaze and resolvesapi_keyfromINTERFAZE_API_KEY. Not imported from the package root — the core SDK stays langchain-free; importinginterfaze.langchainwithout the extra raises a clearInterfazeError.Scope
Per the chosen approach this is the in-repo subclass, not the separately published
langchain-interfazepackage (which the issue's strategic recommendation describes). No PyPI release; ships as an optional extra with mocked unit tests.Tests
12 new (
tests/test_langchain.py, guarded byimportorskip): defaults + override, key resolution, custom fields surfaced (sync/stream/async), request precontext injected/omitted, video url + base64 → file part, streaming tag-strip. Suite: 36 passing;ruff+mypy --strictclean; import smoke test passes.Known limitations (flagged, out of scope)
— resolved by interfaze#218 (deploying): now honored server-side as an alias, no longer a silent no-op.ChatOpenAIrenamesmax_tokens→max_completion_tokensVideoContentBlock(url/base64/file_id), not the v0source_type/datashape.stream().text_deltas()helper (Streamed <precontext>/<think> tags leak to live consumers #4) handles cross-chunk splits.