Unbias / model.py
mfernandar95
variable name changes
fd14147
from google import genai
import os
api_key = os.getenv("api_key")
def process_text(cv,key):
client = genai.Client(api_key=api_key) #my key
question ='''Transform the following text by making all words gender-neutral while maintaining grammatical correctness and natural readability.
Do not change the language of the text—preserve the original language exactly. Additionally, replace all names with a unique identifier and make sure the email uses this as well (e.g., 'Alice' → 'Person_1') to preserve anonymity. Handle contextual cases where direct substitution is not ideal.
Guidelines:
Full Gender Neutralization:
Replace all gendered words (not just female-related) with neutral equivalents.
Examples:
He/She → They
Him/Her → Them
His/Hers → Theirs
Boyfriend/Girlfriend → Partner
Brother/Sister → Sibling
Father/Mother → Parent
Husband/Wife → Spouse
Phrase-Level Adjustments:
Modify phrases that assume gender roles (e.g., brotherhood → community, man-made → human-made).
Contextual Rewriting:
If direct replacement sounds unnatural, rephrase for better clarity (e.g., His leadership was strong → Their leadership was strong).
Name Masking:
Replace all personal names with 'Person_X', ensuring that the same name always maps to the same number within the text.
Include a name mapping list at the end of the output.\n'''
script1= question + cv
response = client.models.generate_content(
model="gemini-2.0-flash-lite", contents=script1)
return(response.text)