Cloud LLM extraction: stricter prompt + Zod validation + provider abstraction

Open
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
react-native, typescript
Domain
ai, mobile, testing-qa

Research direction

Start with CloudAiProvider.ts and the existing JobExtractionResult schema, then inspect the extract screen and its EXPO_PUBLIC_ENABLE_CLOUD_AI gating. Review the proposed extraction prompt location at src/ai/prompts/extraction.ts and the current test setup. Done means malformed output is rejected with a friendly error, logs include prompt version and latency, new prompt and parser tests pass, and all 112 existing tests remain green.

Written by the indexing model from the issue text.

Description

enhancement

Problem

CloudAiProvider.ts exists and uses Gemini 3.1 Flash Lite (with Gemini 3 Flash Preview fallback), but the integration is rough:

  • No Zod validation of the LLM's response (Plan §15.3 requires it)
  • Prompt is inline; not reusable / testable
  • No latency or token usage logging
  • Only one provider; no way to add OpenAI / Anthropic / Azure OpenAI without forking
  • No graceful degradation when the API key is missing

Why

  • LLM output is not guaranteed to match the expected JSON shape; the app would currently write garbage into the suggestions UI
  • The PLAN explicitly says the cloud provider should "validate response with Zod"
  • A second provider would be useful for cost/quality comparison
  • Telemetry helps debug and tune the prompt

Proposed solution

  1. Extract the prompt to src/ai/prompts/extraction.ts with versioning
  2. Validate the Gemini response with the existing JobExtractionResult Zod schema before returning
  3. Log latency, prompt version, token counts (if available)
  4. Define a generic CloudLlmAdapter interface so a second provider (OpenAI gpt-4o-mini) can be added behind a feature flag
  5. Hide the cloud provider from the extract screen when EXPO_PUBLIC_ENABLE_CLOUD_AI !== "true" (already partially done)

Acceptance

  • Malformed LLM output is rejected and surfaces a friendly error
  • All 112 existing tests still pass
  • New unit tests for the prompt template + Zod parser
  • Logs include prompt version + latency in console.info (or future telemetry)
Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Taleef7/JobTrail

All issues in Taleef7/JobTrail

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.