Skip to content

Update OpenAI API: use SDK v6 and replace legacy gpt-4-vision-preview model#5

Draft
sepo-agent-app[bot] wants to merge 2 commits into
mainfrom
agent/implement-issue-4/claude-26536075716
Draft

Update OpenAI API: use SDK v6 and replace legacy gpt-4-vision-preview model#5
sepo-agent-app[bot] wants to merge 2 commits into
mainfrom
agent/implement-issue-4/claude-26536075716

Conversation

@sepo-agent-app
Copy link
Copy Markdown

Summary

  • Adds openai@^6.39.0 to package.json dependencies
  • Replaces raw fetch calls in getHtmlFromOpenAI.ts, getCodeFromOpenAI.ts, and getInterpretationFromAI.ts with the official OpenAI SDK (client.chat.completions.create)
  • Upgrades deprecated gpt-4-vision-previewgpt-4o in getHtmlFromOpenAI.ts
  • Fixes generateCode.tsx and interpretShapes.tsx to remove stale json.error checks (SDK throws on API errors) and handle null-safe content via ?? ''

Test plan

  • npm install completes without dependency errors
  • TypeScript build (npx tsc --noEmit) passes with no errors
  • All three OpenAI functions use the SDK client with dangerouslyAllowBrowser: true
  • No references to gpt-4-vision-preview remain in the codebase
  • No raw fetch calls to api.openai.com remain in lib files

Closes #4

🤖 Generated with Claude Code

@ryanyen2
Copy link
Copy Markdown
Contributor

@sepo-agent /orchestrate

@sepo-agent-app

This comment has been minimized.

@sepo-agent-app

This comment has been minimized.

Comment thread app/lib/generateCode.tsx Outdated
Comment thread app/lib/interpretShapes.tsx Outdated
@sepo-agent-app

This comment has been minimized.

@sepo-agent-app

This comment has been minimized.

@sepo-agent-app
Copy link
Copy Markdown
Author

Sepo pushed fixes for this PR. Branch: agent/implement-issue-4/claude-26536075716. Requested by @sepo-agent.

  • Removed unreachable if (!json) { throw Error('Could not contact OpenAI.') } dead-code blocks from app/lib/generateCode.tsx (lines 94–96) and app/lib/interpretShapes.tsx (lines 135–137) — the SDK always returns or throws, never null.
  • Added a one-line intent comment above dangerouslyAllowBrowser: true in all three SDK client files (getHtmlFromOpenAI.ts, getCodeFromOpenAI.ts, getInterpretationFromAI.ts) clarifying the flag is intentional for this client-side demo app.

@sepo-agent-app
Copy link
Copy Markdown
Author

sepo-agent-app Bot commented May 27, 2026

Sepo is dispatching follow-up automation.

Source Next Target Round Status
fix-pr review PR #5 4 / 12 Dispatched

Reason: agent planner selected review: fix-pr succeeded on PR #5 (OpenAI SDK v6 migration). A review pass is warranted to verify the applied fixes are correct and the PR is ready for human review.

@sepo-agent-app
Copy link
Copy Markdown
Author

No agent/rubrics branch exists in this repository (confirmed again). The previous rubric review in round 2 already returned N/A for the same reason.

Rubrics Review

Total Score Verdict Rubrics Scored
N/A N/A 0
Dimension Rubric Result Score Evidence
not applicable N/A No agent/rubrics branch found for CodeShaping/annotate-edit; no user/team rubrics are configured

Notes

  • No rubrics are configured for this repository. The agent/rubrics branch does not exist, so there is nothing to score against.
  • This is round 4 of the orchestration loop (review pass after fix-pr). The prior fix-pr pass pushed changes to agent/implement-issue-4/claude-26536075716 addressing: removal of unreachable if (!json) dead-code blocks in generateCode.tsx and interpretShapes.tsx, and addition of intent comments at all three dangerouslyAllowBrowser: true instantiation sites.
  • The PR diff confirms those changes are present in the current head (d62a5d197): dead-code guards removed, ?? '' null-coalescing applied, and intent comments added in at least getCodeFromOpenAI.ts. The PR is in a clean state for human review.
  • To enable rubric scoring, initialize the agent/rubrics branch (e.g., via @sepo-agent /rubrics).

Findings

  • INFO: No rubrics configured — scoring cannot proceed until the agent/rubrics branch is created.
  • INFO (observation): fix-pr changes appear correctly applied. PR Update OpenAI API: use SDK v6 and replace legacy gpt-4-vision-preview model #5 now: removes bespoke fetch boilerplate (~200 lines), uses typed SDK v6 responses, upgrades gpt-4-vision-previewgpt-4o, removes unreachable null guards, and documents the dangerouslyAllowBrowser intent. No new issues introduced.

Final Rubric Verdict

N/A

@sepo-agent-app
Copy link
Copy Markdown
Author

AI Review Synthesis

Dual-agent review by Claude and Codex.
Requested by @ryanyen2.

Summary of PR/Issue

PR #5 migrates three hand-rolled fetch-based OpenAI wrappers (getCodeFromOpenAI.ts, getHtmlFromOpenAI.ts, getInterpretationFromAI.ts) from ~200 lines of bespoke boilerplate and locally re-invented type aliases to the official openai SDK v6 (openai@^6.39.0). It also upgrades the deprecated gpt-4-vision-preview model to gpt-4o. Two caller files (generateCode.tsx, interpretShapes.tsx) are updated to remove stale null-check guards and apply ?? '' null-coalescing on the SDK's string | null content field. The PR closes #4. A prior fix-pr pass (round 3) applied all mechanical fixes identified in the previous review cycle.

Review

All previously flagged WARNING-level issues have been resolved by the round-3 fix-pr agent. The current head (d62a5d197) is correct, complete, and ready for merge. Remaining findings are INFO-level, pre-existing, and non-blocking.

Issue Severity Description
No actionable issues remain INFO All WARNING findings (dead-code guards, missing dangerouslyAllowBrowser intent comments) confirmed fixed. Remaining observations are pre-existing or acceptable for this project's conventions.
Per-call OpenAI client instantiation INFO Each of the three wrapper functions creates a fresh client on every call. Acceptable because apiKey is user-supplied at call time and the SDK is stateless between calls; no blocker.
catch (e: any) wraps typed SDK errors INFO SDK error subtypes (APIError, RateLimitError, etc.) are collapsed to generic Error(e.message). Same behavior as prior raw-fetch implementation — not a regression, not a blocker.
getHtmlFromOpenAI.ts unreferenced INFO Pre-existing dead code; migrating it for consistency is the correct call. Noted for awareness only.
No automated tests INFO Test plan is fully manual; consistent with existing repo conventions. Not a blocker.

Progress

  • Dead-code if (!json) { throw Error('Could not contact OpenAI.') } blocks removed from generateCode.tsx and interpretShapes.tsx — fixed in round-3 fix-pr pass.
  • Dead-code if (json?.error) blocks removed — fixed in the original PR.
  • ?? '' null-coalescing on message.content applied in both callers — correct, SDK types content as string | null.
  • gpt-4-vision-preview fully replaced by gpt-4o in getHtmlFromOpenAI.ts.
  • Intent comment added above dangerouslyAllowBrowser: true at all three SDK instantiation sites — fixed in round-3 fix-pr pass.
  • Local hand-rolled type aliases (MessageContent, GPT4VCompletionRequest, GPT4oCompletionRequest) fully deleted.
  • No rubrics configured for this repository (agent/rubrics branch does not exist) — rubric scoring is N/A.
  • Inline thread cleanup this pass: Resolved two stale same-agent threads — PRRT_kwDOMNKfpc6FOMBP (app/lib/generateCode.tsx) and PRRT_kwDOMNKfpc6FOMC6 (app/lib/interpretShapes.tsx) — both confirmed fixed by the round-3 fix-pr commit.

Issue Details

No blocking or warning-level issues remain. All INFO findings are listed in the table above and require no branch changes.

Recommended Next Step

NO_AUTOMATED_ACTION — all concrete, automatable findings have been applied. The PR is ready for human review and merge.

Final Verdict

SHIP

Action Items

  • (Optional) Consider initializing agent/rubrics branch to enable rubric scoring on future PRs (@sepo-agent /rubrics)

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.

Goal: update API connection to the latest

2 participants