Skip to content

feat(python): add Windows-friendly Codex chat with image support - #115

Open
lfu45757-star wants to merge 1 commit into
corespeed-io:mainfrom
lfu45757-star:feat/python-codex-image-chat
Open

lfu45757-star wants to merge 1 commit into
corespeed-io:mainfrom
lfu45757-star:feat/python-codex-image-chat

Conversation

@lfu45757-star

Copy link
Copy Markdown

Summary

Add an optional, Windows-friendly Python bridge for chatting with a locally
authenticated Codex CLI, including single-image understanding and follow-up
questions about the most recent image.

Relationship to #110

Related to #110, but independent and complementary rather than a replacement:

#110 This PR
Entry point Node.js bridge + installable skill; macOS/Linux Python SDK example + Windows launcher
Input Text tasks Text and one static image
Context Resume an explicit Codex session Bounded in-memory text history + latest image
Execution Workspace-writing task agent Chat-only, read-only sandbox, tools disabled
Image lifecycle Not implemented Validation, bounded download, 30-minute expiry, per-call temporary-file cleanup

This PR does not modify the skill/Node.js files proposed in #110 or change the
existing default echo example. It is based on the current upstream main, not
the older source archive used for local deployment.

Changes

  • Add python/examples/codex_bot.py, codex_images.py and start-codex.cmd.
  • Restrict handling to the QR-login account, filter stale/duplicate messages and
    preserve ordinary text conversation with bounded history.
  • Attach normalized images using codex exec --image; support mixed image/text
    messages and separate follow-up messages. New images replace old ones.
  • /reset clears both text and image context; image expiry and normal exit also
    release cached image data. No arbitrary files, multi-image comparisons, voice,
    video or remote computer-operation tools are enabled.
  • Validate supported static formats, 10 MiB / 25 MP limits, EXIF orientation and
    metadata removal, and resize to a 2048-pixel maximum edge. Original decrypted
    images stay off disk; normalized temporary JPEGs are removed after each call,
    including error, timeout and cancellation paths.
  • Add backward-compatible download_raw(..., max_bytes=None) to the Python SDK.
    When set, limit both the encrypted stream (with AES padding allowance) and
    decrypted bytes, including when Content-Length is absent.
  • Add an optional Pillow extra, public setup/privacy/troubleshooting documentation,
    regression tests and Python CI dependency/CLI-help coverage.
  • Ignore .venv/ and .codex-wechat/. No credentials, real user messages/images,
    machine-specific deployment paths, installed environments or runtime records
    are included.

Validation

  • Windows / Python 3.12 offline regression suite against this upstream-based
    integration: 73 tests passed, plus 15 parameter subtests.
  • python examples/codex_bot.py --help: passed without logging into WeChat.
  • git diff --check: passed.
  • The original local implementation was also live-tested with the Windows
    desktop-bundled Codex CLI 0.162.0-alpha.17.2: text returned CODEX_OK, and image
    input correctly read a synthetic image containing six random digits not present
    in the text prompt. Those CLI invocations did not connect to WeChat or send
    WeChat test messages.
  • The CI changes exercise offline Python tests and help output on Windows,
    macOS and Linux. These new remote CI runs have not been claimed as passing yet.

Limitations

  • This example needs a compatible native Codex executable and an image-capable
    model. Required CLI flags and the locally tested version are documented; it
    does not add another API key or make model calls in CI.
  • It defaults to Chinese replies/help. Setup documentation includes English and a
    Chinese quick reference.
  • Only the latest image is retained, for 30 minutes; follow-ups do not extend the
    expiry. Separate messages receive separate replies, not delayed batching.
  • The SDK handles messages sequentially. Reset/help during an active model call
    is processed after the call finishes or times out (default 180 seconds).
  • A forced process kill/power loss may leave temporary files. Local reset does not
    delete content already submitted to Codex/OpenAI.
  • Live image transport through WeChat still requires user acceptance testing;
    no running local WeChat service was interrupted for this contribution.

中文摘要

补充 #110 尚未覆盖的 Windows/Python 图文聊天用法:单图识别、最近图片追问、
/reset 同时清空文字与图片,以及图片下载限额、格式校验和临时文件清理。
这是关闭电脑操作工具的聊天示例,不替代 #110 的任务执行和会话续接方案。

Add owner-only text/image chat, latest-image follow-ups, reset and image
lifecycle handling. Bound SDK media downloads without changing defaults,
and include offline tests, CI coverage and public setup documentation.

Complementary to corespeed-io#110.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant