Skip to content

Revamping Pyodide blog post#99

Merged
jpchauvel merged 1 commit into
mainfrom
pyodide
May 14, 2026
Merged

Revamping Pyodide blog post#99
jpchauvel merged 1 commit into
mainfrom
pyodide

Conversation

@jpchauvel
Copy link
Copy Markdown
Collaborator

@jpchauvel jpchauvel commented May 14, 2026

Summary by CodeRabbit

  • Documentation
    • Updated blog post demonstrating GPT-5.4-mini integration via OpenRouter.
    • Enhanced error handling with dedicated feedback mechanisms.
    • Modernized JavaScript Pyodide integration from updated sources.
    • Streamlined Python backend with persistent conversation history.
    • Improved async request handling and module registration.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

Blog post tutorial updated to demonstrate a Python/Pyodide chat application using GPT-5.4-mini via OpenRouter instead of GPT-3.5 Turbo. Front-matter, UI markup, JavaScript Pyodide integration, Python backend implementation, and repository links refreshed accordingly.

Changes

Chat tutorial and code sample refresh

Layer / File(s) Summary
Article metadata and introduction
blog/haciendo-app-chat-gpt-con-tech-pyodide.md
Front-matter and early article text switched from GPT-3.5 context to GPT-5.4-mini model reference.
UI markup and JavaScript Pyodide setup
blog/haciendo-app-chat-gpt-con-tech-pyodide.md
HTML/CSS interface and JavaScript setup rewritten to load Pyodide from updated CDN, register JS module with displayResponse and displayError functions, load Python packages, fetch app bundle, prompt for OpenRouter API key, and wire send/Enter handlers to Python backend.
Python backend implementation
blog/haciendo-app-chat-gpt-con-tech-pyodide.md
Python backend replaced to target GPT-5.4-mini via OpenRouter with base_url="https://openrouter.ai/api/v1", add SYSTEM_PROMPT, maintain multi-turn history, use httpx.AsyncClient with request hook to strip "stainless" headers, implement handle_message to append messages to history, create completions, return via JS module, and rollback on error.
Concluding narrative and repository links
blog/haciendo-app-chat-gpt-con-tech-pyodide.md
Backend narrative updated from GPT-3.5 to GPT-5.4-mini wording, and final code/demo links section refreshed with new repository references and call-to-action text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A blog post blooms with GPT-5 delight,
Pyodide dances, JavaScript shines bright,
Python speaks through the browser's might,
OpenRouter channels flow just right,
Hop along, dear reader, into the light! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Revamping Pyodide blog post' accurately describes the main change: updating/revamping a blog post about Pyodide with significant modernizations to code examples and content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pyodide

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
blog/haciendo-app-chat-gpt-con-tech-pyodide.md (3)

398-402: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Update narrative to match the actual implementation.

The text describes a custom URLLib3Transport class that no longer exists in the code. The Python code comment (lines 296-299) explicitly states that "Modern Pyodide (>= 0.27.2) ships openai, httpx, and urllib3 as bundled packages with built-in Emscripten/Fetch transports, so no custom HTTP transport is needed anymore."

This section should be rewritten to describe the actual implementation: using the built-in httpx transport with an event hook to strip stainless headers for OpenRouter CORS compatibility.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@blog/haciendo-app-chat-gpt-con-tech-pyodide.md` around lines 398 - 402,
Update the narrative to remove references to the non-existent URLLib3Transport
and instead describe that the implementation uses httpx's built-in transport
provided by modern Pyodide (per the in-file comment around the earlier Pyodide
note) and an httpx event hook to strip the "stainless" headers for OpenRouter
CORS compatibility; mention the actual symbols used (httpx, event hook that
removes stainless headers, OpenRouter) and briefly state that custom
Emscripten/Fetch transports are no longer necessary.

452-452: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update model reference to GPT-5.4-mini.

The conclusion still mentions "GPT-3" but the entire tutorial has been updated to use GPT-5.4-mini. This should be corrected for consistency.

📝 Proposed fix
-GPT-3 en un entorno basado en la web, ofreciendo una interfaz interactiva para
+GPT-5.4-mini en un entorno basado en la web, ofreciendo una interfaz interactiva para
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@blog/haciendo-app-chat-gpt-con-tech-pyodide.md` at line 452, Replace the
outdated model name "GPT-3" in the conclusion (and any other occurrences) with
"GPT-5.4-mini" to match the rest of the tutorial; search for the literal string
"GPT-3" (e.g., the sentence "GPT-3 en un entorno basado en la web, ofreciendo
una interfaz interactiva para") and update it to "GPT-5.4-mini" so the
conclusion and tutorial are consistent with the implemented model.

420-426: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove outdated reference to custom transport layer.

This section continues to describe the old URLLib3Transport approach and references a GitHub issue workaround that is no longer used. The current implementation uses modern Pyodide's built-in transports with an httpx request hook to strip headers.

This outdated explanation should be removed or replaced with a description of the current approach: using httpx.AsyncClient(event_hooks={"request": [_strip_stainless]}) to handle OpenRouter's CORS requirements.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@blog/haciendo-app-chat-gpt-con-tech-pyodide.md` around lines 420 - 426,
Remove the outdated paragraph that promotes the custom URLLib3Transport and the
GitHub workaround; instead, replace it with a concise explanation that the
implementation now uses Pyodide's built-in transports with an httpx request hook
to strip problematic headers, e.g. using
httpx.AsyncClient(event_hooks={"request": [_strip_stainless]}) to satisfy
OpenRouter CORS requirements—mention URLLib3Transport only as deprecated and
reference the _strip_stainless hook and httpx.AsyncClient usage so readers can
locate the current implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@blog/haciendo-app-chat-gpt-con-tech-pyodide.md`:
- Around line 459-463: Update the markdown to consistently state that an
OpenRouter API token is required: change the text at the locations that
currently read "tokens de OpenRouter" and "Necesitas un token de OpenAI" to
explicitly say "token de OpenRouter (OpenRouter API key)". Also ensure any
explanatory text or links referencing authentication align with the code's
base_url="https://openrouter.ai/api/v1" and the prompt label "OpenRouter API
key" so readers aren’t directed to use an OpenAI token by mistake.

---

Outside diff comments:
In `@blog/haciendo-app-chat-gpt-con-tech-pyodide.md`:
- Around line 398-402: Update the narrative to remove references to the
non-existent URLLib3Transport and instead describe that the implementation uses
httpx's built-in transport provided by modern Pyodide (per the in-file comment
around the earlier Pyodide note) and an httpx event hook to strip the
"stainless" headers for OpenRouter CORS compatibility; mention the actual
symbols used (httpx, event hook that removes stainless headers, OpenRouter) and
briefly state that custom Emscripten/Fetch transports are no longer necessary.
- Line 452: Replace the outdated model name "GPT-3" in the conclusion (and any
other occurrences) with "GPT-5.4-mini" to match the rest of the tutorial; search
for the literal string "GPT-3" (e.g., the sentence "GPT-3 en un entorno basado
en la web, ofreciendo una interfaz interactiva para") and update it to
"GPT-5.4-mini" so the conclusion and tutorial are consistent with the
implemented model.
- Around line 420-426: Remove the outdated paragraph that promotes the custom
URLLib3Transport and the GitHub workaround; instead, replace it with a concise
explanation that the implementation now uses Pyodide's built-in transports with
an httpx request hook to strip problematic headers, e.g. using
httpx.AsyncClient(event_hooks={"request": [_strip_stainless]}) to satisfy
OpenRouter CORS requirements—mention URLLib3Transport only as deprecated and
reference the _strip_stainless hook and httpx.AsyncClient usage so readers can
locate the current implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5a01dcf4-a918-455f-8066-cf148d466737

📥 Commits

Reviewing files that changed from the base of the PR and between d6aa508 and b6bd158.

📒 Files selected for processing (1)
  • blog/haciendo-app-chat-gpt-con-tech-pyodide.md

Comment on lines +459 to +463
Puedes encontrar el código completo aquí: https://github.com/jpchauvel/pyodide-chat-gpt2
(Con este código, puedes probarlo con tokens de OpenRouter).

[¡Pruébalo ahora!](https://chauvel.org/blog/pyodide-chat-gpt/)

(Necesitas un token de OpenAI)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify which API token is required.

There's confusion about which API token users need:

  • Line 460 says: "Con este código, puedes probarlo con tokens de OpenRouter"
  • Line 463 says: "Necesitas un token de OpenAI"

Since the code uses base_url="https://openrouter.ai/api/v1" (line 339) and prompts for an "OpenRouter API key" (line 214), both links should consistently indicate that an OpenRouter token is required, not an OpenAI token.

📝 Proposed fix
 Puedes encontrar el código completo aquí: https://github.com/jpchauvel/pyodide-chat-gpt2
 (Con este código, puedes probarlo con tokens de OpenRouter).

 [¡Pruébalo ahora!](https://chauvel.org/blog/pyodide-chat-gpt/)
-(Necesitas un token de OpenAI)
+(Necesitas un token de OpenRouter)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Puedes encontrar el código completo aquí: https://github.com/jpchauvel/pyodide-chat-gpt2
(Con este código, puedes probarlo con tokens de OpenRouter).
[¡Pruébalo ahora!](https://chauvel.org/blog/pyodide-chat-gpt/)
(Necesitas un token de OpenAI)
Puedes encontrar el código completo aquí: https://github.com/jpchauvel/pyodide-chat-gpt2
(Con este código, puedes probarlo con tokens de OpenRouter).
[¡Pruébalo ahora!](https://chauvel.org/blog/pyodide-chat-gpt/)
(Necesitas un token de OpenRouter)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@blog/haciendo-app-chat-gpt-con-tech-pyodide.md` around lines 459 - 463,
Update the markdown to consistently state that an OpenRouter API token is
required: change the text at the locations that currently read "tokens de
OpenRouter" and "Necesitas un token de OpenAI" to explicitly say "token de
OpenRouter (OpenRouter API key)". Also ensure any explanatory text or links
referencing authentication align with the code's
base_url="https://openrouter.ai/api/v1" and the prompt label "OpenRouter API
key" so readers aren’t directed to use an OpenAI token by mistake.

@jpchauvel jpchauvel merged commit aa9ed35 into main May 14, 2026
2 checks passed
@jpchauvel jpchauvel deleted the pyodide branch May 14, 2026 00:21
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.

2 participants