gperdrizet commited on
Commit
edc4b6c
·
1 Parent(s): 91b2483

Added input for additional instructions from user for writer agent, in addition to stock prompt from configuration.py

Browse files
Files changed (4) hide show
  1. .gitignore +2 -1
  2. functions/gradio.py +14 -3
  3. functions/writer_agent.py +25 -2
  4. resumate.py +14 -2
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  __pycache__
2
  .vscode
3
- .venv
 
 
1
  __pycache__
2
  .vscode
3
+ .venv
4
+ data
functions/gradio.py CHANGED
@@ -14,7 +14,7 @@ logging.basicConfig(level=logging.INFO)
14
  logger = logging.getLogger(__name__)
15
 
16
 
17
- def process_inputs(linkedin_pdf, github_url, job_post_text):
18
  """
19
  Process the input files and URLs from the Gradio interface.
20
 
@@ -22,6 +22,7 @@ def process_inputs(linkedin_pdf, github_url, job_post_text):
22
  linkedin_pdf: Uploaded LinkedIn resume export PDF file
23
  github_url (str): GitHub profile URL
24
  job_post_text (str): Job post text content
 
25
 
26
  Returns:
27
  str: Formatted output with file and URL information
@@ -78,14 +79,22 @@ def process_inputs(linkedin_pdf, github_url, job_post_text):
78
  result += "❌ Job post not provided\n"
79
  logger.info("No job post text provided")
80
 
 
 
 
 
 
 
 
 
81
  logger.info("Input processing completed")
82
 
83
- resume = write_resume(extraction_result)
84
 
85
  return result
86
 
87
 
88
- def get_processed_data(linkedin_pdf, github_url, job_post_text):
89
  """
90
  Get structured data from all inputs for further processing.
91
 
@@ -93,6 +102,7 @@ def get_processed_data(linkedin_pdf, github_url, job_post_text):
93
  linkedin_pdf: Uploaded LinkedIn resume export PDF file
94
  github_url (str): GitHub profile URL
95
  job_post_text (str): Job post text content
 
96
 
97
  Returns:
98
  dict: Structured data containing all processed information
@@ -101,6 +111,7 @@ def get_processed_data(linkedin_pdf, github_url, job_post_text):
101
  "linkedin": None,
102
  "github": None,
103
  "job_post": job_post_text.strip() if job_post_text and job_post_text.strip() else None,
 
104
  "errors": []
105
  }
106
 
 
14
  logger = logging.getLogger(__name__)
15
 
16
 
17
+ def process_inputs(linkedin_pdf, github_url, job_post_text, user_instructions):
18
  """
19
  Process the input files and URLs from the Gradio interface.
20
 
 
22
  linkedin_pdf: Uploaded LinkedIn resume export PDF file
23
  github_url (str): GitHub profile URL
24
  job_post_text (str): Job post text content
25
+ user_instructions (str): Additional instructions from the user
26
 
27
  Returns:
28
  str: Formatted output with file and URL information
 
79
  result += "❌ Job post not provided\n"
80
  logger.info("No job post text provided")
81
 
82
+ # Process user instructions
83
+ if user_instructions and user_instructions.strip():
84
+ result += "✅ Additional instructions provided\n"
85
+ logger.info(f"User instructions provided ({len(user_instructions)} characters)")
86
+ else:
87
+ result += "ℹ️ No additional instructions provided\n"
88
+ logger.info("No additional instructions provided")
89
+
90
  logger.info("Input processing completed")
91
 
92
+ resume = write_resume(extraction_result, user_instructions)
93
 
94
  return result
95
 
96
 
97
+ def get_processed_data(linkedin_pdf, github_url, job_post_text, user_instructions):
98
  """
99
  Get structured data from all inputs for further processing.
100
 
 
102
  linkedin_pdf: Uploaded LinkedIn resume export PDF file
103
  github_url (str): GitHub profile URL
104
  job_post_text (str): Job post text content
105
+ user_instructions (str): Additional instructions from the user
106
 
107
  Returns:
108
  dict: Structured data containing all processed information
 
111
  "linkedin": None,
112
  "github": None,
113
  "job_post": job_post_text.strip() if job_post_text and job_post_text.strip() else None,
114
+ "user_instructions": user_instructions.strip() if user_instructions and user_instructions.strip() else None,
115
  "errors": []
116
  }
117
 
functions/writer_agent.py CHANGED
@@ -2,19 +2,21 @@
2
 
3
  import json
4
  import logging
 
5
  from smolagents import CodeAgent
6
  from configuration import AGENT_MODEL, INSTRUCTIONS
7
 
8
  logging.basicConfig(level=logging.INFO)
9
  logger = logging.getLogger(__name__)
10
 
11
- def write_resume(content: str) -> str:
12
 
13
  """
14
  Generates a resume based on the provided content.
15
 
16
  Args:
17
  content (str): The content to be used for generating the resume.
 
18
 
19
  Returns:
20
  str: The generated resume.
@@ -32,10 +34,31 @@ def write_resume(content: str) -> str:
32
  planning_interval=5
33
  )
34
 
 
 
 
 
 
 
35
  submitted_answer = agent.run(
36
- INSTRUCTIONS + '\n' + json.dumps(content['structured_text']),
37
  )
38
 
39
  logger.info("submitted_answer: %s", submitted_answer)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  return submitted_answer
 
2
 
3
  import json
4
  import logging
5
+ import os
6
  from smolagents import CodeAgent
7
  from configuration import AGENT_MODEL, INSTRUCTIONS
8
 
9
  logging.basicConfig(level=logging.INFO)
10
  logger = logging.getLogger(__name__)
11
 
12
+ def write_resume(content: str, user_instructions: str = None) -> str:
13
 
14
  """
15
  Generates a resume based on the provided content.
16
 
17
  Args:
18
  content (str): The content to be used for generating the resume.
19
+ user_instructions (str, optional): Additional instructions from the user.
20
 
21
  Returns:
22
  str: The generated resume.
 
34
  planning_interval=5
35
  )
36
 
37
+ # Prepare instructions - combine default with user instructions
38
+ instructions = INSTRUCTIONS
39
+ if user_instructions and user_instructions.strip():
40
+ instructions += f"\n\nAdditional user instructions:\n{user_instructions.strip()}"
41
+ logger.info("Added user instructions to agent prompt")
42
+
43
  submitted_answer = agent.run(
44
+ instructions + '\n' + json.dumps(content['structured_text']),
45
  )
46
 
47
  logger.info("submitted_answer: %s", submitted_answer)
48
+
49
+ # Create data directory if it doesn't exist
50
+ data_dir = 'data'
51
+ if not os.path.exists(data_dir):
52
+ os.makedirs(data_dir)
53
+ logger.info("Created data directory: %s", data_dir)
54
+
55
+ # Save the resume to resume.md in the data directory
56
+ resume_file_path = os.path.join(data_dir, 'resume.md')
57
+ try:
58
+ with open(resume_file_path, 'w', encoding='utf-8') as f:
59
+ f.write(submitted_answer)
60
+ logger.info("Resume saved to: %s", resume_file_path)
61
+ except Exception as e:
62
+ logger.error("Failed to save resume to file: %s", e)
63
 
64
  return submitted_answer
resumate.py CHANGED
@@ -67,12 +67,24 @@ with gr.Blocks() as demo:
67
  placeholder="Copy and paste the job post text here"
68
  )
69
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  submit_btn = gr.Button("Submit")
71
- output = gr.Textbox(label="Output", lines=20, max_lines=50, show_copy_button=True)
72
 
73
  submit_btn.click( # pylint: disable=no-member
74
  process_inputs,
75
- inputs=[linkedin_pdf, github_profile, job_post],
76
  outputs=output
77
  )
78
 
 
67
  placeholder="Copy and paste the job post text here"
68
  )
69
 
70
+ gr.Markdown("""
71
+ ## 4. Additional instructions (optional)
72
+
73
+ Provide any additional instructions or adjustments for the resume writer agent. This could include specific formatting preferences, emphasis on certain skills, or any other customizations you'd like.
74
+ """)
75
+
76
+ user_instructions = gr.Textbox(
77
+ label="Additional Instructions",
78
+ placeholder="Enter any additional instructions for the resume writer (optional)",
79
+ lines=3
80
+ )
81
+
82
  submit_btn = gr.Button("Submit")
83
+ output = gr.Textbox(label="Output", lines=5, max_lines=50, show_copy_button=True)
84
 
85
  submit_btn.click( # pylint: disable=no-member
86
  process_inputs,
87
+ inputs=[linkedin_pdf, github_profile, job_post, user_instructions],
88
  outputs=output
89
  )
90