Repository navigation
Closed
Labels
Language: PythonPertains to the Python implementation of TypeChat.Pertains to the Python implementation of TypeChat.SuggestionNew feature or requestNew feature or request
Description
Goal
Add backward-compatible Python support for text-and-image prompts, matching the existing TypeScript prompt capabilities.
This is an owner-requested tracking item. It is separate from the Python authentication/client-injection work in #516 and the TypeScript authentication parity PR. No Python implementation is included in those changes.
Scope and acceptance criteria
- Extend public Python prompt types to accept existing string content and explicitly typed text/image parts, including image URLs and data URLs. Preserve current string-only callers without migration.
- Forward supported multimodal content through both the built-in HTTP Chat Completions model and the configured-client adapter from Add dependency-free Python token providers and client adapters #516. Do not silently drop, stringify, or coerce image parts into unconstrained values.
- Document how applications provide image context through the existing model/translator prompt surfaces. Keep ordinary
translate(str)calls compatible. - Preserve prompt ordering and image context across validation/repair attempts. Do not weaken schema generation, result validation, or explicit error behavior.
- Keep authentication, application-owned SDK clients, retries/timeouts, and HTTP response-size controls consistent with the relevant model path.
- Add no required SDK, Azure Identity, or image-processing dependencies. TypeChat should forward image references, not fetch images or introduce image generation.
- Add deterministic offline tests for existing text prompts, mixed text/images, URL/data-URL images, both model paths, malformed/unsupported prompt parts, and translator repair.
- Update the Python documentation with a minimal text-and-image example and supported-format limitations.
Boundaries
This item covers text/image input, not audio/video input, image generation, streaming, or agent orchestration. Responses API support is a separate work item; text/image support should not require that API migration. Add combined-path regression coverage when both capabilities are available.
Context
- [Python] Support using keyless auth for Azure OpenAI #216 and Add dependency-free Python token providers and client adapters #516 address reusable authentication and configured model clients, not multimodal prompt typing.
- TypeScript already exposes typed text/image prompt content; use it as compatibility/design evidence rather than weakening Python typing or validation.
Metadata
Metadata
Assignees
Labels
Language: PythonPertains to the Python implementation of TypeChat.Pertains to the Python implementation of TypeChat.SuggestionNew feature or requestNew feature or request
Activity
robgruen commentedon Nov 4, 2026
/typechat propose
github-actions commentedon Nov 4, 2026
Work proposal P1
Proposal for community discussion, not accepted work or permission to build.
Recommendation
I recommend an additive change to Python's existing Chat Completions path, the message-based model API, rather than a new backend or a Responses API migration. PromptSection.content is currently typed as a string, but both built-in model paths already forward message dictionaries. The translator also retains its preamble when it appends correction messages after invalid output, so the existing surfaces are a practical starting point.
Export typed dictionary definitions for tagged text and image_url parts, allowing either existing string content or an ordered list of those parts. Forward image URLs, data URLs, and the optional image-processing detail setting of auto, low, or high unchanged. Use the same structural checks before either path sends a request, reject malformed or unsupported parts without echoing their contents, and keep completion responses text-only. TypeChat would not fetch or decode images.
Use model.complete for message lists and translate with prompt_preamble, the context messages placed before the generated schema request; keep translate's request parameter a string. This avoids another translator API while retaining image context during repair and preserving each path's authentication, retry, and client-ownership behavior. Build on the merged Python adapter in PR 516 and hillary-mutisya's merged TypeScript image contribution in PR 254. PR 519 is an unmerged TypeScript reference, not a Python implementation or a dependency of this proposal.
For the initial Python contract, I recommend images only in user messages and part lists containing explicitly tagged objects rather than bare strings. This keeps the request shape explicit instead of copying the more permissive string-in-array option in the original TypeScript contribution. Do your intended integrations require images in system or assistant messages, or bare strings inside part lists? The issue does not specify those cases, and the answers are needed to finalize these compatibility boundaries.
Changes since the previous proposal
Direction and readiness
The frozen GOALS.md policy supports this additive Python integration under G1 and G4, reliable input/output validation and repair under G2, compatibility with existing implementations under G3, and documentation and deterministic regressions under G5. Forwarding image references through existing interfaces does not introduce application business logic under N2, a vendor-dependent core under N3, or orchestration under N1. Explicit prompt checks and unchanged schema validation respect N4. The separate Responses API work is not required by this recommendation.
A concrete approach and observable criteria can be recommended, but the issue does not settle whether image parts are needed outside user messages or whether Python must accept bare strings within part lists for TypeScript parity. The recommendation is user-only images and explicitly tagged parts, not an assertion that those boundaries are agreed. These compatibility questions need answers before an owner acceptance decision; the open TypeScript PR does not answer them for Python.
Goal
Python applications can provide typed text and image references through existing Chat Completions model and translator interfaces and obtain validated structured results without changing text-only callers or authentication setup.
Scope
Non-goals
Acceptance criteria
Open questions
Evidence limits and assumptions
Related contributions: #254, #516, #519.
Not eligible for acceptance yet. Discuss the remaining questions and request
/typechat proposeagain.Proposal run | Approved scope policy
robgruen commentedon Nov 4, 2026
I don't think we need image parts in the system or assistant messages.
We don't necessarily have to have TypeScript parity but flexibility is always good.
Also, we need to consider #241. While the implementation is out of date the idea is a good one and is on the roadmap so we need to consider that future work as part of this update.
robgruen commentedon Nov 4, 2026
/typechat propose
github-actions commentedon Nov 4, 2026
TypeChat: A proposal was not confirmed. Inspect the run and thread before retrying; do not assume nothing was posted.
Owner request | Run
Operational receipt only. This comment does not publish draft text, accept work, authorize implementation, or approve merging.
robgruen commentedon Nov 4, 2026
/typechat reply
github-actions commentedon Nov 4, 2026
Keeping image parts in user messages fits this change; I would leave system and assistant messages text-only. Exact TypeScript parity is not necessary to preserve Python compatibility: keep whole-string messages and use explicitly tagged text/image parts rather than bare strings inside part lists. Python's PromptSection.content is still typed as str, although both the HTTP model and the configured-client adapter already forward message dictionaries. The missing piece is a supported typed contract with consistent input checks on both paths.
Guido van Rossum's PR 241 is relevant to how those messages are assembled. It proposes separating schema instructions from the current user request and placing conversation history between them. The inspected translator instead places prompt_preamble, the application's context messages, before a user message containing both schema and request. It retains those context messages when asking the model to repair invalid output, so image-bearing user messages could use that surface without changing ordinary translate(str) calls.
I recommend keeping structured image parts independent of that layout and preserving the current ordering in this item, rather than adopting PR 241's outdated implementation. Its discussion reported worse results with system prompts and left schema placement and repair-message roles unsettled. Future prompting work should preserve image-bearing user messages and repair context rather than concatenate or stringify them. This would extend the Python client adapter merged in PR 516 and draw on hillary-mutisya's image types from PR 254. PR 519 is now merged too, but provides TypeScript integration code, not Python multimodal support.
I would start with image context through prompt_preamble and leave any change to how the translator accepts the current request for a separate, explicit decision. That avoids coupling image transport to a new prompting scheme while still considering PR 241's direction. Is image context through prompt_preamble sufficient for this version, or do you need translate itself to accept a current request made of text and image parts?
Related contributions: #241, #254, #516, #519.
Automated response requested by the project owner. This does not accept work or authorize implementation.
robgruen commentedon Nov 4, 2026
agreed.
robgruen commentedon Nov 4, 2026
/typechat propose
github-actions commentedon Nov 4, 2026
Work proposal P2
Proposal for community discussion, not accepted work or permission to build.
Recommendation
I recommend keeping this as an additive Python Chat Completions update, using the existing message-based model API. Supply images through user messages in model.complete or prompt_preamble, the context messages passed to translate, and keep translate's current request a string. That follows your user-only guidance and the later agreement with using the preamble, without introducing a second translator request format or waiting for the separate Responses API work.
Use TypedDict definitions, which describe required dictionary fields, for tagged text and image_url parts. Preserve whole-string content in every existing role, allow tagged text parts in those roles, and allow images only in user messages. I recommend tagged objects rather than bare strings inside part lists: Python has no documented list contract to preserve, and exact TypeScript parity is not required. Both built-in paths should apply the same structural checks, preserve image references and ordering, and return explicit failures without echoing prompt contents.
Keep message parts independent of schema placement so Guido van Rossum's PR 241 can later separate schema instructions, conversation history and the current request without redesigning image transport. Concatenating image-bearing history into text would lose that structure. PR 241 remains unmerged: its older reports of worse system-prompt results and later favorable but provisional review do not settle schema placement or repair roles. This item should preserve today's ordering rather than adopt or duplicate that prompting change.
Build on the merged Python client adapter from PR 516 and hillary-mutisya's TypeScript image types and example from PR 254 and PR 258. PR 519 is now merged too, but provides TypeScript integration code, not Python multimodal support. Forward hosted-image references and data URLs, which embed encoded image data, unchanged; do not fetch or decode images. Keep output text-only, preserve authentication and client ownership, and cover both model paths and translator repair with offline regressions. Individual providers and models still determine supported image formats and limits.
Changes since the previous proposal
Direction and readiness
Under the supplied approved policy, typed image context for application-defined interfaces fits G1 and G4. Preserving schema checks, strict output validation and controlled repair respects G2 and N4. Additive Python changes and unchanged TypeScript behavior fit G3; documentation and deterministic regressions fit G5. The proposal introduces neither orchestration under N1, application business logic under N2, nor a required vendor SDK under N3. PR 241 and Python Responses work are not adopted here. N5 leaves acceptance to the human direction owner, robgruen.
The recorded user-only guidance, relaxed parity requirement and agreement following the preamble recommendation leave no blocking interface question for these bounded terms. Tagged-only lists remain a concrete recommendation, not a claim of consensus on every design detail. PR 241 and Python Responses remain separate work rather than dependencies. Observable criteria are provided for an owner decision; informal agreement is not treated as work acceptance or permission to implement.
Goal
Python applications can supply typed text and image references through existing Chat Completions model and translator context interfaces and obtain validated structured results without migrating string-only callers or changing authentication setup.
Scope
Non-goals
Acceptance criteria
Evidence limits and assumptions
Related contributions: #241, #254, #258, #516, #519.
The owner may accept these exact terms with
/typechat accept P2. Acceptance does not start a build.Proposal run | Approved scope policy
robgruen commentedon Nov 4, 2026
/typechat accept P2
github-actions commentedon Nov 4, 2026
Accepted work
Approved by the project owner, robgruen, for issue #517. Proposal P2.
Goal
Python applications can supply typed text and image references through existing Chat Completions model and translator context interfaces and obtain validated structured results without migrating string-only callers or changing authentication setup.
Scope
Non-goals
Acceptance criteria
Existing contributions
Proposal run | Approved scope policy
This accepts the scope above. It does not start or authorize an automated implementation run, increase any budget, or approve merging. Material scope changes require a new proposal and owner decision.
After separate owner authorization and pilot activation, use
/typechat build P2.robgruen commentedon Nov 5, 2026
/typechat build P2