Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,13 @@ if not cohere_api_key:
|
|
| 14 |
co = cohere.Client(cohere_api_key)
|
| 15 |
|
| 16 |
def generate_body(job_description, language):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Set the language model based on user selection
|
| 18 |
model = 'command-xlarge-nightly' # Default to command-xlarge-nightly model for both English and German
|
| 19 |
|
|
@@ -30,6 +37,25 @@ def generate_body(job_description, language):
|
|
| 30 |
return response.generations[0].text.strip()
|
| 31 |
|
| 32 |
def create_application_letter(name, address, email, phone, job_position, employer_name, greeting_option, employer_contact_name, employer_address, job_id, start_date, job_description, language, output_format):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Generate the body using the job description and language
|
| 34 |
body = generate_body(job_description, language)
|
| 35 |
|
|
@@ -100,13 +126,28 @@ def create_application_letter(name, address, email, phone, job_position, employe
|
|
| 100 |
return output_filename_docx
|
| 101 |
|
| 102 |
def generate_and_download(name, address, email, phone, job_position, employer_name, greeting_option, employer_contact_name, employer_address, job_id, start_date, job_description, language, output_format):
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
output_filename = create_application_letter(name, address, email, phone, job_position, employer_name, greeting_option, employer_contact_name, employer_address, job_id, start_date, job_description, language, output_format)
|
| 105 |
-
# Return the file for download
|
| 106 |
return output_filename
|
| 107 |
|
| 108 |
# Define the Gradio interface
|
| 109 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
name = gr.Textbox(label="Name", placeholder="Enter your full name", value="Claire Waßer")
|
| 111 |
address = gr.Textbox(label="Address", placeholder="Enter your address", value="Musterstraße 78, 23456 Musterstadt")
|
| 112 |
email = gr.Textbox(label="Email", placeholder="Enter your email", value="Email@email.de")
|
|
|
|
| 14 |
co = cohere.Client(cohere_api_key)
|
| 15 |
|
| 16 |
def generate_body(job_description, language):
|
| 17 |
+
"""
|
| 18 |
+
Generate the body of a job application letter using Cohere's language model.
|
| 19 |
+
|
| 20 |
+
:param job_description: The description of the job you are applying for.
|
| 21 |
+
:param language: The language in which the letter should be written (English or German).
|
| 22 |
+
:return: The generated body text for the job application letter.
|
| 23 |
+
"""
|
| 24 |
# Set the language model based on user selection
|
| 25 |
model = 'command-xlarge-nightly' # Default to command-xlarge-nightly model for both English and German
|
| 26 |
|
|
|
|
| 37 |
return response.generations[0].text.strip()
|
| 38 |
|
| 39 |
def create_application_letter(name, address, email, phone, job_position, employer_name, greeting_option, employer_contact_name, employer_address, job_id, start_date, job_description, language, output_format):
|
| 40 |
+
"""
|
| 41 |
+
Create a job application letter with the provided details and format it for download.
|
| 42 |
+
|
| 43 |
+
:param name: Applicant's full name.
|
| 44 |
+
:param address: Applicant's address.
|
| 45 |
+
:param email: Applicant's email address.
|
| 46 |
+
:param phone: Applicant's phone number.
|
| 47 |
+
:param job_position: Position being applied for.
|
| 48 |
+
:param employer_name: Employer's name.
|
| 49 |
+
:param greeting_option: Indicates whether the recipient's name is known.
|
| 50 |
+
:param employer_contact_name: Employer contact's name (if known).
|
| 51 |
+
:param employer_address: Employer's address.
|
| 52 |
+
:param job_id: Job ID for the application.
|
| 53 |
+
:param start_date: Desired start date for the job.
|
| 54 |
+
:param job_description: The job description.
|
| 55 |
+
:param language: Language of the letter (English or German).
|
| 56 |
+
:param output_format: Desired output format (DOCX or PDF).
|
| 57 |
+
:return: The filename of the generated application letter.
|
| 58 |
+
"""
|
| 59 |
# Generate the body using the job description and language
|
| 60 |
body = generate_body(job_description, language)
|
| 61 |
|
|
|
|
| 126 |
return output_filename_docx
|
| 127 |
|
| 128 |
def generate_and_download(name, address, email, phone, job_position, employer_name, greeting_option, employer_contact_name, employer_address, job_id, start_date, job_description, language, output_format):
|
| 129 |
+
"""
|
| 130 |
+
Generate the application letter and return the file for download.
|
| 131 |
+
|
| 132 |
+
:return: Filename of the generated application letter for download.
|
| 133 |
+
"""
|
| 134 |
output_filename = create_application_letter(name, address, email, phone, job_position, employer_name, greeting_option, employer_contact_name, employer_address, job_id, start_date, job_description, language, output_format)
|
|
|
|
| 135 |
return output_filename
|
| 136 |
|
| 137 |
# Define the Gradio interface
|
| 138 |
with gr.Blocks() as demo:
|
| 139 |
+
gr.Markdown("""
|
| 140 |
+
## Professional Job Application Letter Generator
|
| 141 |
+
|
| 142 |
+
This tool helps you generate a professional job application letter in either English or German.
|
| 143 |
+
The letter is automatically formatted and can be downloaded in DOCX or PDF format.
|
| 144 |
+
|
| 145 |
+
### Powered by Cohere's Language Model
|
| 146 |
+
|
| 147 |
+
The body of the application letter is generated using **Cohere**, a state-of-the-art language model,
|
| 148 |
+
ensuring that your application is not only well-written but also tailored to the job description you provide.
|
| 149 |
+
""")
|
| 150 |
+
|
| 151 |
name = gr.Textbox(label="Name", placeholder="Enter your full name", value="Claire Waßer")
|
| 152 |
address = gr.Textbox(label="Address", placeholder="Enter your address", value="Musterstraße 78, 23456 Musterstadt")
|
| 153 |
email = gr.Textbox(label="Email", placeholder="Enter your email", value="Email@email.de")
|