feat(ai): wire DifficultyEstimator to real backend AI endpoint (#1574) - #1669
Conversation
…us-Labs#1574) The DifficultyEstimator page returned hardcoded results (Hard/94%/35 Minutes/same 4 prerequisites) for every question, and no backend endpoint existed to produce a genuine estimate. Backend: - Add difficultyEstimatePrompt() to utils/prompts.js - Add estimateDifficulty controller to aiController.js that calls generateWithFallback and validates the Gemini JSON response with Zod (difficulty enum, confidence 0-100, estimatedTime, prerequisites, analysis) - Add validateEstimateDifficulty Zod middleware in ValidateAi.js - Mount POST /api/ai/estimate-difficulty (protect + aiLimiter + sensitiveRouteHeaders) in server.js Frontend: - Add ESTIMATE_DIFFICULTY to apiPaths.js - Rewrite DifficultyEstimator.jsx to POST to the endpoint with loading and error states (react-hot-toast), and render dynamic results (difficulty-colored badge, confidence, estimated time, analysis text, prerequisite chips). Removed all hardcoded values. Closes Canopus-Labs#1574 Closes Canopus-Labs#1648 Co-authored-by: openhands <openhands@all-hands.dev>
|
Warning Review limit reached
Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Comment |
| const rawText = await result.response.text(); | ||
| let cleanedText = rawText | ||
| .replace(/^(\s*```json\s*|\s*```\s*)+/i, "") | ||
| .replace(/(\s*```\s*)+$/i, "") |
|
@saidai-bhuvanesh Take a look on github bot suggestion |
The DifficultyEstimator page returned hardcoded results (
Hard/94%/35 Minutes/same 4 prerequisites) for every question, and no backend endpoint existed to produce a genuine estimate.Backend
difficultyEstimatePrompt()toutils/prompts.jsestimateDifficultycontroller inaiController.jsthat callsgenerateWithFallbackand validates the Gemini JSON response with Zod (difficultyenum,confidence0-100,estimatedTime,prerequisites,analysis)validateEstimateDifficultyZod middleware inValidateAi.jsPOST /api/ai/estimate-difficulty(protect+aiLimiter+sensitiveRouteHeaders) inserver.jsFrontend
ESTIMATE_DIFFICULTYtoapiPaths.jsDifficultyEstimator.jsxto POST to the endpoint with loading and error states (react-hot-toast), rendering dynamic results (difficulty-colored badge, confidence, estimated time, analysis text, prerequisite chips). All hardcoded values removed.Frontend build verified:
vite buildpasses cleanly.Closes #1574
Closes #1648
This PR was created by an AI agent (OpenHands) on behalf of saidai-bhuvanesh.