Skip to content

Ai tone grammer check#94

Merged
aniruddhaadak80 merged 6 commits intoaniruddhaadak80:mainfrom
paratha14:ai_tone_grammer_check
Mar 9, 2026
Merged

Ai tone grammer check#94
aniruddhaadak80 merged 6 commits intoaniruddhaadak80:mainfrom
paratha14:ai_tone_grammer_check

Conversation

@paratha14
Copy link
Contributor

@paratha14 paratha14 commented Mar 9, 2026

Description/Context

Adds an optional Tone & Grammar Critique feature to the AI Resume Optimizer. When toggled on, the AI analyses the rewritten resume for passive voice, weak verbs, and grammatical errors — returning an overall tone score, per-bullet issue breakdown with fix suggestions, and grammar corrections. Also fixes a TypeScript bug where optimizeResume was being called with 3 arguments but only accepted 2.

  • Fixes: # (N/A)

Type of Change

  • [] 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Refactor (code improvement without functional change)
  • 📚 Documentation Update
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)

Visuals (if applicable)

image image

Checklist before requesting a review

  • I have read the CONTRIBUTING.md guide.
  • I have tested these changes locally (no build errors).
  • My code successfully passes npm run lint.
  • My code follows the consistent styling/patterns of the codebase.
  • I have added/updated comments in complex logic.

@vercel
Copy link

vercel bot commented Mar 9, 2026

@paratha14 is attempting to deploy a commit to the Aniruddha Adak's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link

netlify bot commented Mar 9, 2026

👷 Deploy request for career-zen pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit fef7ac2

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional Tone & Grammar Critique feature to the AI Resume Optimizer. When the user enables a toggle switch, the AI analyzes the resume for passive voice, weak verbs, and grammatical errors — returning a tone score, per-bullet issue breakdown with fix suggestions, and grammar corrections. The PR also updates the optimizeResume function to accept a third options parameter and adds corresponding TypeScript interfaces.

Changes:

  • Adds new TypeScript interfaces (ToneIssue, GrammarError, ToneAndGrammarAnalysis, AnalysisResult, AnalyzeResumeOptions) and extends the analyzeResumeWithGemini function to optionally include tone & grammar critique in the Gemini prompt.
  • Adds a ToneGrammarPanel UI component and a toggle switch in the pre-optimize pane of ResumeOptimizer.tsx, along with the plumbing to pass includeToneCritique through the server action.
  • Updates the /api/analyze route and optimizeResume server action to accept and forward the includeToneCritique option.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lib/gemini.ts New interfaces for tone/grammar analysis; extended prompt to include optional tone critique block; added return type annotation
src/app/actions/optimize.ts Extended optimizeResume to accept options; added tone critique prompt injection and a parallel analyzeResumeWithGemini call
src/app/api/analyze/route.ts Reads includeToneCritique from FormData and passes it to analyzeResumeWithGemini
src/components/ResumeOptimizer.tsx Added ToneGrammarPanel component, toggle switch UI, updated icon imports, various formatting/comment cleanups
package-lock.json Minor dependency version bumps (minimatch, ajv, underscore)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +86 to +127
${includeToneCritique ? `
TONE & GRAMMAR CRITIQUE (include this extra key in your JSON output):
Also analyse the rewritten resume bullets and summary for tone and grammar issues.
Add the following key at the top level of the JSON object:
"toneAndGrammar": {
"overallToneScore": <integer 0-100>,
"passiveVoiceCount": <integer — number of passive-voice phrases found>,
"weakVerbCount": <integer — count of weak/vague verbs like "helped", "assisted", "worked on">,
"summary": "<1-2 sentence overall critique>",
"toneStrengths": ["<strength 1>", "<strength 2>"],
"toneIssues": [
{ "original": "<original phrase>", "issue": "<why it's weak>", "suggestion": "<stronger rewrite>" }
],
"grammarErrors": [
{ "original": "<original text>", "issue": "<grammar rule broken>", "correction": "<corrected text>" }
]
}
` : ''}
`;

try {
const response = await generateContentWithRetry(ai, {
model: "gemini-3-flash-preview",
contents: prompt,
config: {
responseMimeType: "application/json",
}
});
// Run optimization (and optionally tone analysis) in parallel
const [optimizeResponse, toneAnalysis] = await Promise.all([
generateContentWithRetry(ai, {
model: "gemini-3-flash-preview",
contents: prompt,
config: { responseMimeType: "application/json" },
}),
includeToneCritique
? analyzeResumeWithGemini(resumeText, jobDescription, { includeToneCritique: true })
: Promise.resolve(null),
]);

const text = response.text;
const text = optimizeResponse.text;
if (!text) throw new Error("No response from AI");

return { success: true, data: JSON.parse(text) };
const data = JSON.parse(text);

// Attach tone & grammar analysis if requested
if (toneAnalysis?.toneAndGrammar) {
data.toneAndGrammar = toneAnalysis.toneAndGrammar;
}
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When includeToneCritique is true, the optimization prompt (lines 86-103) already instructs Gemini to include toneAndGrammar in its JSON output. However, the code also makes a separate parallel call to analyzeResumeWithGemini (line 115), which is a completely different AI prompt that analyses the original resume text (not the rewritten one). This causes two problems:

  1. Redundant API call: Two Gemini API calls are made for tone analysis when only one is needed. This doubles the latency/cost for the tone critique feature.
  2. Wrong input text: The parallel analyzeResumeWithGemini call analyses the original resume, while the prompt in this function asks Gemini to critique the rewritten resume. Then at line 125-126, the result from analyzeResumeWithGemini overwrites whatever the optimization call returned, so the user sees tone analysis of the original resume, not the optimized one.

You should either (a) remove the prompt additions at lines 86-103 and rely solely on the parallel call, or (b) remove the parallel analyzeResumeWithGemini call and use the toneAndGrammar key already returned by the optimization response. Option (b) is likely better since it analyses the rewritten resume, which matches the PR description.

Copilot uses AI. Check for mistakes.
) : (
<FileType2 className="h-5 w-5" />
)}
{isDownloading === 'DOCX' ? <Loader2 className="h-5 w-5 animate-spin" /> : <FileText className="h-5 w-5" />}
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DOCX download button previously used FileType2 as its icon but has been changed to use FileText — the same icon as the PDF button. This makes both buttons visually identical (apart from color and label), reducing the visual distinction between formats. Meanwhile, FileType2 is still imported on line 6 but is now unused. Either restore FileType2 for the DOCX button or remove the unused import.

Suggested change
{isDownloading === 'DOCX' ? <Loader2 className="h-5 w-5 animate-spin" /> : <FileText className="h-5 w-5" />}
{isDownloading === 'DOCX' ? <Loader2 className="h-5 w-5 animate-spin" /> : <FileType2 className="h-5 w-5" />}

Copilot uses AI. Check for mistakes.
// Tone & Grammar Results Panel
// ─────────────────────────────────────────────────────────────────────────────

function ToneGrammarPanel({ data }: { data: any }) {
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToneGrammarPanel accepts data: any, but the ToneAndGrammarAnalysis interface is already defined and exported from @/lib/gemini. Using the proper type would provide compile-time safety and autocomplete, and is consistent with the typed interfaces added in this PR. Import and use ToneAndGrammarAnalysis instead of any.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +29

original: string;

issue: string;

Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ToneIssue interface has extra blank lines between its properties and lacks JSDoc comments, while the adjacent GrammarError interface (lines 33-40) uses JSDoc comments consistently for each property. For consistency, add JSDoc comments to ToneIssue properties and remove the extraneous blank lines.

Suggested change
original: string;
issue: string;
/** The original text with the tone issue */
original: string;
/** A plain-English explanation of the tone problem */
issue: string;
/** A suggested rewrite with improved tone */

Copilot uses AI. Check for mistakes.
@aniruddhaadak80 aniruddhaadak80 merged commit a6054a3 into aniruddhaadak80:main Mar 9, 2026
5 of 6 checks passed
@aniruddhaadak80
Copy link
Owner

Description/Context

Adds an optional Tone & Grammar Critique feature to the AI Resume Optimizer. When toggled on, the AI analyses the rewritten resume for passive voice, weak verbs, and grammatical errors — returning an overall tone score, per-bullet issue breakdown with fix suggestions, and grammar corrections. Also fixes a TypeScript bug where optimizeResume was being called with 3 arguments but only accepted 2.

  • Fixes: # (N/A)

Type of Change

  • [] 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Refactor (code improvement without functional change)
  • 📚 Documentation Update
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)

Visuals (if applicable)

image image

Checklist before requesting a review

  • I have read the CONTRIBUTING.md guide.
  • I have tested these changes locally (no build errors).
  • My code successfully passes npm run lint.
  • My code follows the consistent styling/patterns of the codebase.
  • I have added/updated comments in complex logic.

thank you so much @paratha14, for your wonderful contributions 🎉🎉🎊

@paratha14
Copy link
Contributor Author

I had a Great time working on this. Let's stay in touch for future collaborations! A follow would be much appreciated.

@aniruddhaadak80
Copy link
Owner

I had a Great time working on this. Let's stay in touch for future collaborations! A follow would be much appreciated.

sure, I just sent the LinkedIn connection request. We will be in touch there.

Thanks again. If you can, you can work on other issues too or suggest an improvement and work on that also.

btw, thanks again.

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.

3 participants