Skip to content

feat(backend): add optional Gemma 3n E4B AI provider#13

Merged
danieleforte92 merged 1 commit into
developfrom
codex/add-gemma-3n-e4b-ai-provider-support
Feb 9, 2026
Merged

feat(backend): add optional Gemma 3n E4B AI provider#13
danieleforte92 merged 1 commit into
developfrom
codex/add-gemma-3n-e4b-ai-provider-support

Conversation

@danieleforte92

Copy link
Copy Markdown
Owner

Motivation

  • Add optional support for the Gemma 3n E4B model (via an Ollama-compatible local runtime) so backend-only AI helpers can draft recipes, suggest ingredient categories, and explain previews.
  • Keep PantryOps fully functional without AI by gating calls behind a feature flag and returning safe fallbacks when the provider is unavailable.
  • Provide a minimal, non-mutative integration surface so UI work can be added later without changing core domain logic.

Description

  • Added a small AI integration layer under backend/src/ai/ including aiProvider.ts (interface + errors), ollamaProvider.ts (generic Ollama-backed implementation), gemma3nProvider.ts (default provider wrapper), and aiService.ts (feature-flagged provider selection + fallback builder).
  • Added light HTTP endpoints in backend/src/routes/ai.ts to validate input and proxy requests: POST /api/ai/recipe-draft, POST /api/ai/category-suggest, and POST /api/ai/explain-preview.
  • Registered the AI routes in server.ts and included backend/src/ai/README.md documenting environment variables (AI_ENABLED, AI_PROVIDER, OLLAMA_BASE_URL, OLLAMA_TIMEOUT_MS, OLLAMA_MODEL), default behavior, and the endpoints.
  • AI is disabled by default (AI_ENABLED=false), the service returns a 503 when disabled and a safe fallback response when provider calls fail; the integration never mutates stock/recipes by itself.

Testing

  • No automated tests were executed as part of this change (bun test not run).

Codex Task

Repository owner deleted a comment from chatgpt-codex-connector Bot Feb 9, 2026
@danieleforte92

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danieleforte92 danieleforte92 marked this pull request as ready for review February 9, 2026 17:19
@danieleforte92 danieleforte92 merged commit a15b640 into develop Feb 9, 2026
2 checks passed
@danieleforte92 danieleforte92 deleted the codex/add-gemma-3n-e4b-ai-provider-support branch February 9, 2026 17:21
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