ak0601 commited on
Commit
4b9360f
·
verified ·
1 Parent(s): 256893e

Update app_hug.py

Browse files
Files changed (1) hide show
  1. app_hug.py +66 -12
app_hug.py CHANGED
@@ -114,6 +114,11 @@ class GenerateMessageRequest(BaseModel):
114
  message_type: MessageType
115
  send_email: bool = False
116
  past_conversation: Optional[str] = Field(None, description="(Optional) Previous messages with candidate")
 
 
 
 
 
117
 
118
  class FeedbackRequest(BaseModel):
119
  message: str
@@ -276,14 +281,23 @@ def refine_message_with_feedback(
276
  lines = content.split('\n')
277
  body_found = False
278
  body_lines = []
 
279
  for line in lines:
280
- if line.strip().startswith('SUBJECT:'):
281
- subject_line = line.replace('SUBJECT:', '').strip()
282
- elif line.strip().startswith('BODY:'):
 
 
283
  body_found = True
284
- elif body_found and line.strip():
285
  body_lines.append(line)
 
286
  body_content = '\n'.join(body_lines).strip()
 
 
 
 
 
287
  if not subject_line:
288
  subject_line = "Recruitment Opportunity - Updated"
289
  if not body_content:
@@ -302,7 +316,12 @@ def generate_recruitment_message_with_subject(
302
  current_pos: str,
303
  evaluation: Optional[str] = None,
304
  feedback: Optional[str] = None,
305
- past_conversation: Optional[str] = None
 
 
 
 
 
306
  ) -> Tuple[str, str]:
307
  api_key = os.getenv("OPENAI_API_KEY")
308
  llm = ChatOpenAI(
@@ -333,6 +352,18 @@ def generate_recruitment_message_with_subject(
333
  - Candidate: {candidate}
334
  - Candidate's current position: {current_pos}
335
  """
 
 
 
 
 
 
 
 
 
 
 
 
336
  if evaluation:
337
  base_prompt += f"- Evaluation: {evaluation}\n"
338
  prompt = base_prompt
@@ -394,14 +425,23 @@ def generate_recruitment_message_with_subject(
394
  lines = content.split('\n')
395
  body_found = False
396
  body_lines = []
 
397
  for line in lines:
398
- if line.strip().startswith('SUBJECT:'):
399
- subject_line = line.replace('SUBJECT:', '').strip()
400
- elif line.strip().startswith('BODY:'):
 
 
401
  body_found = True
402
- elif body_found and line.strip():
403
  body_lines.append(line)
 
404
  body_content = '\n'.join(body_lines).strip()
 
 
 
 
 
405
  if not subject_line:
406
  subject_line = f"Opportunity at {company} - {role_title}"
407
  if not body_content:
@@ -599,7 +639,12 @@ async def generate_message(
599
  job_evaluation: Optional[str] = Query(None, description="Recruiter's evaluation of candidate for the job"),
600
  reply_to_email: Optional[str] = Query(None, description="Recruiter's email for reply-to header"),
601
  send_email: bool = Query(False, description="Whether to send the email"),
602
- past_conversation: Optional[str] = Query(None, description="Previous messages with candidate")
 
 
 
 
 
603
  ):
604
  try:
605
  current_position = f"{current_role} at {current_company}"
@@ -612,7 +657,12 @@ async def generate_message(
612
  candidate=candidate_name,
613
  current_pos=current_position,
614
  evaluation=job_evaluation,
615
- past_conversation=past_conversation
 
 
 
 
 
616
  )
617
  email_sent = False
618
  if send_email:
@@ -756,4 +806,8 @@ async def get_documentation():
756
 
757
  if __name__ == "__main__":
758
  import uvicorn
759
- uvicorn.run(app, host="0.0.0.0", port=8000)
 
 
 
 
 
114
  message_type: MessageType
115
  send_email: bool = False
116
  past_conversation: Optional[str] = Field(None, description="(Optional) Previous messages with candidate")
117
+ job_location: Optional[str] = Field(None, description="(Optional) Job location (e.g., 'Sterling, VA')")
118
+ company_blurb: Optional[str] = Field(None, description="(Optional) Brief description of company mission/industry")
119
+ culture: Optional[str] = Field(None, description="(Optional) Company culture description (e.g., 'fast-moving, tight-knit team')")
120
+ job_responsibilities: Optional[str] = Field(None, description="(Optional) Key responsibilities and duties for the role")
121
+ candidate_experience: Optional[str] = Field(None, description="(Optional) Specific skills and experience of the candidate")
122
 
123
  class FeedbackRequest(BaseModel):
124
  message: str
 
281
  lines = content.split('\n')
282
  body_found = False
283
  body_lines = []
284
+
285
  for line in lines:
286
+ line_stripped = line.strip()
287
+ # Handle both plain text and markdown formats
288
+ if line_stripped.startswith('SUBJECT:') or line_stripped.startswith('**SUBJECT:**'):
289
+ subject_line = line_stripped.replace('SUBJECT:', '').replace('**SUBJECT:**', '').replace('**', '').strip()
290
+ elif line_stripped.startswith('BODY:') or line_stripped.startswith('**BODY:**'):
291
  body_found = True
292
+ elif body_found and line_stripped:
293
  body_lines.append(line)
294
+
295
  body_content = '\n'.join(body_lines).strip()
296
+
297
+ # Clean up any remaining markdown formatting from body
298
+ if body_content:
299
+ body_content = body_content.replace('**', '')
300
+
301
  if not subject_line:
302
  subject_line = "Recruitment Opportunity - Updated"
303
  if not body_content:
 
316
  current_pos: str,
317
  evaluation: Optional[str] = None,
318
  feedback: Optional[str] = None,
319
+ past_conversation: Optional[str] = None,
320
+ job_location: Optional[str] = None,
321
+ company_blurb: Optional[str] = None,
322
+ culture: Optional[str] = None,
323
+ job_responsibilities: Optional[str] = None,
324
+ candidate_experience: Optional[str] = None
325
  ) -> Tuple[str, str]:
326
  api_key = os.getenv("OPENAI_API_KEY")
327
  llm = ChatOpenAI(
 
352
  - Candidate: {candidate}
353
  - Candidate's current position: {current_pos}
354
  """
355
+
356
+ # Add optional additional details if provided
357
+ if job_location:
358
+ base_prompt += f"- Job location: {job_location}\n"
359
+ if company_blurb:
360
+ base_prompt += f"- Company description: {company_blurb}\n"
361
+ if culture:
362
+ base_prompt += f"- Company culture: {culture}\n"
363
+ if job_responsibilities:
364
+ base_prompt += f"- Job responsibilities: {job_responsibilities}\n"
365
+ if candidate_experience:
366
+ base_prompt += f"- Candidate's specific experience: {candidate_experience}\n"
367
  if evaluation:
368
  base_prompt += f"- Evaluation: {evaluation}\n"
369
  prompt = base_prompt
 
425
  lines = content.split('\n')
426
  body_found = False
427
  body_lines = []
428
+
429
  for line in lines:
430
+ line_stripped = line.strip()
431
+ # Handle both plain text and markdown formats
432
+ if line_stripped.startswith('SUBJECT:') or line_stripped.startswith('**SUBJECT:**'):
433
+ subject_line = line_stripped.replace('SUBJECT:', '').replace('**SUBJECT:**', '').replace('**', '').strip()
434
+ elif line_stripped.startswith('BODY:') or line_stripped.startswith('**BODY:**'):
435
  body_found = True
436
+ elif body_found and line_stripped:
437
  body_lines.append(line)
438
+
439
  body_content = '\n'.join(body_lines).strip()
440
+
441
+ # Clean up any remaining markdown formatting from body
442
+ if body_content:
443
+ body_content = body_content.replace('**', '')
444
+
445
  if not subject_line:
446
  subject_line = f"Opportunity at {company} - {role_title}"
447
  if not body_content:
 
639
  job_evaluation: Optional[str] = Query(None, description="Recruiter's evaluation of candidate for the job"),
640
  reply_to_email: Optional[str] = Query(None, description="Recruiter's email for reply-to header"),
641
  send_email: bool = Query(False, description="Whether to send the email"),
642
+ past_conversation: Optional[str] = Query(None, description="Previous messages with candidate"),
643
+ job_location: Optional[str] = Query(None, description="Job location (e.g., 'Sterling, VA')"),
644
+ company_blurb: Optional[str] = Query(None, description="Brief description of company mission/industry"),
645
+ culture: Optional[str] = Query(None, description="Company culture description (e.g., 'fast-moving, tight-knit team')"),
646
+ job_responsibilities: Optional[str] = Query(None, description="Key responsibilities and duties for the role"),
647
+ candidate_experience: Optional[str] = Query(None, description="Specific skills and experience of the candidate")
648
  ):
649
  try:
650
  current_position = f"{current_role} at {current_company}"
 
657
  candidate=candidate_name,
658
  current_pos=current_position,
659
  evaluation=job_evaluation,
660
+ past_conversation=past_conversation,
661
+ job_location=job_location,
662
+ company_blurb=company_blurb,
663
+ culture=culture,
664
+ job_responsibilities=job_responsibilities,
665
+ candidate_experience=candidate_experience
666
  )
667
  email_sent = False
668
  if send_email:
 
806
 
807
  if __name__ == "__main__":
808
  import uvicorn
809
+ uvicorn.run(app, host="0.0.0.0", port=8000)
810
+
811
+
812
+
813
+ # Additional Infor: Job Location, Company Blurb, Culture, Job Responsibilities, Candidate Experience