import random import requests from bs4 import BeautifulSoup from .constants import API_KEY def remove_html_tags(text): text = text.replace("
", "\n") soup = BeautifulSoup(text, "html.parser") for item in soup.find_all("li"): item_text = item.get_text() item.replace_with(f"\n- {item_text}") cleaned_text = soup.get_text().strip('"').replace('\\"', '"') return cleaned_text def api_call(url, payload, headers=None): headers = { "x-api-key": API_KEY, "Content-Type": "application/json" } try: response = requests.post(url, headers=headers, json=payload) return response except Exception as e: print(f"Error: {str(e)}") return "Error: Unable to reach the API or invalid response received." def generate_session_id(): return random.randint(3000, 20000) def highlight_feedback(feedback_output): if not feedback_output["feedback_by_category"]: return False, [(str(feedback_output["feedback_text"]), None)] return True, [(item["text"], item["category"]) for item in feedback_output["feedback_by_category"]] def show_popup(selected_resume, selected_company, selected_job_description): if selected_resume: return """Notice: You selected the option to include the candidate's resume.
Notice: You selected the option to include the company name in the request.
The company name is: InnovateTech Solutions.
Notice: You selected the option to include the job description.
The job requires {total_job_skills} skills, and the candidate has {proven_skills_count} proven skills. " f"There are {unproven_skills_count} unproven skills and {missing_skills_count} missing skills.