Skip to content

Fix Phase 1 AI bugs: Gemini model, analytics fallback, SQL extraction#24

Merged
Mukku27 merged 1 commit into
mainfrom
cursor/fix-ai-bugs-6a40
Jul 10, 2026
Merged

Fix Phase 1 AI bugs: Gemini model, analytics fallback, SQL extraction#24
Mukku27 merged 1 commit into
mainfrom
cursor/fix-ai-bugs-6a40

Conversation

@Mukku27

@Mukku27 Mukku27 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

Implements PR A / Phase 1 of the bug-fix plan: unblock the AI path and fix silent SQL/schema prompt failures.

Changes

  1. Current Gemini model — Shared config.DEFAULT_GEMINI_MODEL defaults to gemini-3.5-flash (override with GEMINI_MODEL_NAME). Replaces shut-down gemini-1.5-flash in analytics and SQL generation.
  2. Analytics graceful degradation — Without a key or when the model fails, returns deterministic inventory summaries (counts, value, low stock, categories). UI wraps actions in try/except and writes audit events (analytics_*).
  3. SQL extraction_extract_sql() handles markdown fences and prose wrappers so fenced Gemini output is not discarded for keyword fallback. SQL fallback uses the original question, not the full prompt template.
  4. Full schema in NL→SQLget_product_schema_description() builds prompts from live/PRODUCT_REQUIRED_COLUMNS (includes BRAND, SIZE, COLOR, WEIGHT, SPECIFICATIONS).

Tests

  • ruff check clean on touched files
  • pytest: 77 passed

Out of scope (later PRs)

  • Excel ID-based matching, mapping dedupe (Phase 2)
  • Startup ensure_schema, audit rotation (Phase 3)
  • Plotly dashboard / PandasAI replacement / docs rewrite
Open in Web Open in Cursor 

…traction

- Default to gemini-3.5-flash via shared config.DEFAULT_GEMINI_MODEL
- Analytics returns deterministic summaries when AI is unavailable and audits results
- Extract SQL from markdown fences; fall back using the user question
- NL→SQL prompts include the full PRODUCT schema description

Co-authored-by: Mukesh Vemulapalli <vemulapallimukesh@gmail.com>
@Mukku27
Mukku27 marked this pull request as ready for review July 10, 2026 11:54
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@Mukku27
Mukku27 merged commit dce2834 into main Jul 10, 2026
5 checks passed
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