Refactor: Optimized gemini_model caching and enhanced system prompts#25
Refactor: Optimized gemini_model caching and enhanced system prompts#25ndayiemile merged 1 commit intomainfrom
Conversation
Pull Request Test Coverage Report for Build 18298791312Details
💛 - Coveralls |
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Grammar error in AI instruction ▹ view | ||
| Mixed Business Logic in System Instructions ▹ view | ||
| 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.
| <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> |
There was a problem hiding this comment.
Grammar error in AI instruction 
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
💬 Looking for more details? Reply to this comment to chat with Korbit.
| <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> |
There was a problem hiding this comment.
Mixed Business Logic in System Instructions 
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
💬 Looking for more details? Reply to this comment to chat with Korbit.
| except Exception as e: | ||
| print(f"Error checking file {full_path}: {e}") |
There was a problem hiding this comment.
Generic exception swallowing in file processing 
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
# raiseProvide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
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.