Skip to content

Use backend podcast estimates and remove frontend cost heuristics#474

Open
AJaySi wants to merge 1 commit intomainfrom
codex/remove-heuristic-calculators-and-update-estimates-bhvhnh
Open

Use backend podcast estimates and remove frontend cost heuristics#474
AJaySi wants to merge 1 commit intomainfrom
codex/remove-heuristic-calculators-and-update-estimates-bhvhnh

Conversation

@AJaySi
Copy link
Copy Markdown
Owner

@AJaySi AJaySi commented Apr 19, 2026

Motivation

  • Remove fragile client-side heuristics that duplicated pricing logic and could diverge from real provider costs.
  • Centralize estimate computation in the backend so the UI shows server-provided totals and per-phase breakdowns based on the current pricing catalog.
  • Ensure the frontend displays only backend-provided estimates and shows a clear “Unavailable” fallback when the server does not supply an estimate.

Description

  • Removed the local heuristic estimator from CreateModal.tsx and stopped injecting inferred constants into the create UI by passing estimatedCost={null} into the topic input component.
  • Updated TopicUrlInput.tsx to accept a nullable estimatedCost and render an explicit Est. Unavailable chip when no server estimate is present.
  • Removed the frontend estimateCosts heuristic and now map the backend analysisResp.data.estimate into the frontend CreateProjectResult.estimate (nullable) in frontend/src/services/podcastApi.ts.
  • Extended the frontend PodcastEstimate typing to include backend metadata (breakdown, currency, lastUpdated) and allowed CreateProjectResult.estimate to be null in frontend/src/components/PodcastMaker/types.ts.
  • Added server-side estimate generation in the podcast analysis handler (backend/api/podcast/handlers/analysis.py) that reads pricing catalog entries (cost_per_input_token, cost_per_output_token, cost_per_request, etc.) via PricingService, applies phase-level usage assumptions for Analyze/Gather/Write/Produce, and returns a user-facing estimate payload.
  • Added the estimate field to the API response model PodcastAnalyzeResponse (backend/api/podcast/models.py) so the frontend receives precomputed totals and a phase breakdown.

Testing

  • Ran Python syntax checks with python -m py_compile backend/api/podcast/handlers/analysis.py backend/api/podcast/models.py, which completed successfully.
  • Attempted frontend type validation with npm --prefix frontend run -s typecheck and npm --prefix frontend exec tsc -- --noEmit, but tsc invocation failed in this environment due to npm registry policy (403) and could not complete here.
  • No runtime regressions were observed in server-side compilation steps in this environment after the changes.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant