Rauhan commited on
Commit
a31fc2f
·
1 Parent(s): 2a181a7

UPDATE: antigravity test

Browse files
Files changed (2) hide show
  1. requirements.txt +1 -1
  2. resumeRewritingService.py +18 -15
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
  gradio>=6.1.0
2
- google-generativeai>=0.8.3
3
  pyyaml>=6.0.3
 
1
  gradio>=6.1.0
2
+ google-genai>=0.2.0
3
  pyyaml>=6.0.3
resumeRewritingService.py CHANGED
@@ -1,16 +1,17 @@
1
- import google.generativeai as genai
 
2
  from utils import readPrompts
3
  import os
4
  import re
 
5
 
6
  class ResumeEditService:
7
  def __init__(self):
8
  prompts = readPrompts(path=os.path.join(os.getcwd(), "prompts.yaml"))
9
  self.prompt_template = prompts.get("prompt")
10
 
11
- # Configure the Gemini API
12
- genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
13
- self.model = genai.GenerativeModel('gemini-3-flash-preview')
14
 
15
  def generate_optimized_resume(self, resume_base64: str, job_description: str, current_date: str) -> str:
16
  """
@@ -29,18 +30,20 @@ class ResumeEditService:
29
  prompt = self.prompt_template.replace("{{CURRENT_DATE}}", current_date)
30
  prompt = prompt.replace("{{JOB_DESCRIPTION}}", job_description)
31
 
32
- # Prepare the inline data for the file attachment
33
- # Assuming PDF for now based on app.py, but could support others.
34
- # The app.py reads the file and base64 encodes it without a mime prefix.
35
- # We need to construct the part for the model.
36
 
37
- file_part = {
38
- "mime_type": "application/pdf",
39
- "data": resume_base64
40
- }
41
-
42
- # Generate content
43
- response = self.model.generate_content([prompt, file_part])
 
 
 
 
44
 
45
  # Extract text
46
  response_text = response.text
 
1
+ from google import genai
2
+ from google.genai import types
3
  from utils import readPrompts
4
  import os
5
  import re
6
+ import base64
7
 
8
  class ResumeEditService:
9
  def __init__(self):
10
  prompts = readPrompts(path=os.path.join(os.getcwd(), "prompts.yaml"))
11
  self.prompt_template = prompts.get("prompt")
12
 
13
+ # Configure the Gemini Client
14
+ self.client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
 
15
 
16
  def generate_optimized_resume(self, resume_base64: str, job_description: str, current_date: str) -> str:
17
  """
 
30
  prompt = self.prompt_template.replace("{{CURRENT_DATE}}", current_date)
31
  prompt = prompt.replace("{{JOB_DESCRIPTION}}", job_description)
32
 
33
+ # Decode base64 to bytes for from_bytes
34
+ resume_bytes = base64.b64decode(resume_base64)
 
 
35
 
36
+ # Call the API using the recommended pattern
37
+ response = self.client.models.generate_content(
38
+ model='gemini-3-flash-preview', # Using a stable model name compatible with the new SDK, or revert to user's choice
39
+ contents=[
40
+ types.Part.from_bytes(
41
+ data=resume_bytes,
42
+ mime_type='application/pdf',
43
+ ),
44
+ prompt
45
+ ]
46
+ )
47
 
48
  # Extract text
49
  response_text = response.text