Skip to content

Refactor: Optimized gemini_model caching and enhanced system prompts#25

Merged
ndayiemile merged 1 commit intomainfrom
opt_sysPrompt_n_gModel
Oct 7, 2025
Merged

Refactor: Optimized gemini_model caching and enhanced system prompts#25
ndayiemile merged 1 commit intomainfrom
opt_sysPrompt_n_gModel

Conversation

@ndayiemile
Copy link
Collaborator

@ndayiemile ndayiemile commented Oct 7, 2025

Description by Korbit AI

What change is being made?

Refactor Gemini model caching and system prompts to improve session management, file handling, base knowledge caching, and prompt configuration, including added in-memory LRU tracking, cached MIME detection by extension, and centralized constants for system prompts and model config.

Why are these changes being made?

To improve performance, reliability, and maintainability by reducing redundant uploads, speeding up MIME type determination, tightening session lifecycle with an LRU policy, and standardizing prompts and model configuration for Gemini.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

@coveralls
Copy link

Pull Request Test Coverage Report for Build 18298791312

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 87 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-3.0%) to 77.093%

Files with Coverage Reduction New Missed Lines %
resumax_algo/gemini_model.py 87 19.51%
Totals Coverage Status
Change from base Build 18267417573: -3.0%
Covered Lines: 663
Relevant Lines: 860

💛 - Coveralls

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Readability Grammar error in AI instruction ▹ view
Design Mixed Business Logic in System Instructions ▹ view
Error Handling Generic exception swallowing in file processing ▹ view
Files scanned
File Path Reviewed
resumax_backend/resumax_algo/system_instructions.py
resumax_backend/resumax_algo/gemini_model.py

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

<RULE>Maintain encouraging, pedagogical tone throughout - avoid judgmental language</RULE>
<RULE>Adapt to student level and ask clarifying questions about field, role, skills</RULE>
<RULE>Present suggestions as drafts requiring student's final review</RULE>
<RULE>Don't pretended you know something if user asks about it, you reference it. ie: if they are applying for a role or company you don't know much about, ask them to clarify on what it is</RULE>
Copy link

Choose a reason for hiding this comment

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

Grammar error in AI instruction category Readability

Tell me more
What is the issue?

Grammatical error in the instruction text - 'pretended' should be 'pretend' in the context of giving instructions to the AI system.

Why this matters

This grammatical error could potentially confuse the AI system's understanding of the instruction, leading to inconsistent behavior when handling unknown information requests.

Suggested change ∙ Feature Preview

Change 'Don't pretended' to 'Don't pretend' in the rule text:

<RULE>Don't pretend you know something if user asks about it, you reference it. ie: if they are applying for a role or company you don't know much about, ask them to clarify on what it is</RULE>
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines +83 to +97
<OVERRIDE_PROFESSIONAL_RESUME>
IF Document Type is RESUME AND Target Discipline is STEM or BUSINESS:
* PASS 1 Weighting: HIGH (Focus on 1-page limit, keyword density, and clean section headers).
* PASS 2 Weighting: HIGHEST (If less than 70% of bullet points contain quantifiable metrics, flag as high-priority).
* SECTION CHECK: Mandatory check for Projects section and Technical Skills matrix.
</OVERRIDE_PROFESSIONAL_RESUME>

<OVERRIDE_ACADEMIC_CV>
IF Document Type is ACADEMIC_CV:
* PASS 1 Override: Override the 1-page limit. Check rigorously for consistent citation style (APA, MLA, etc.) within publication lists.
* PASS 2 Focus Shift:
* STEM Research CV: Highest weight shifts to Research Methodology depth and evidence of grant/funding value.
* Humanities/Soc Sci CV: Highest weight shifts to Pedagogical Experience and narrative coherence of the research agenda.
* FEW-SHOT CRITIQUE MANDATE: For lengthy documents, perform an in-depth critique of the first two bullet points of the 'Research Experience' and the first two listed 'Publications.' Extrapolate patterns of error to the rest of the document.
</OVERRIDE_ACADEMIC_CV>
Copy link

Choose a reason for hiding this comment

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

Mixed Business Logic in System Instructions category Design

Tell me more
What is the issue?

Document type-specific logic is embedded in XML-style overrides within the prompt, mixing business logic with the system instructions.

Why this matters

This approach makes it difficult to maintain and extend document-specific rules, and violates the Single Responsibility Principle by combining system instructions with business logic.

Suggested change ∙ Feature Preview

Create a separate document type handler system:

class DocumentTypeHandler:
    def get_critique_rules(self, doc_type: str, discipline: str) -> Dict[str, Any]:
        handlers = {
            'RESUME': self._handle_resume,
            'ACADEMIC_CV': self._handle_academic_cv,
            # Add more handlers
        }
        return handlers.get(doc_type, self._handle_default)(discipline)
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines +170 to +171
except Exception as e:
print(f"Error checking file {full_path}: {e}")
Copy link

Choose a reason for hiding this comment

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

Generic exception swallowing in file processing category Error Handling

Tell me more
What is the issue?

Generic exception handling without re-raising or proper logging loses critical error information that could help debug file processing issues.

Why this matters

When file processing fails, the error is only printed to console and then silently ignored by returning None, making it difficult to diagnose why files aren't being processed correctly in production environments.

Suggested change ∙ Feature Preview

Either re-raise the exception or use proper logging instead of print statements:

except Exception as e:
    import logging
    logger = logging.getLogger(__name__)
    logger.error(f"Error checking file {full_path}: {e}")
    # Consider re-raising if this should be a fatal error
    # raise
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

@ndayiemile ndayiemile merged commit b401c9a into main Oct 7, 2025
2 checks passed
@ndayiemile ndayiemile deleted the opt_sysPrompt_n_gModel branch October 7, 2025 01:06
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