datascientist22 commited on
Commit
63fbb09
β€’
1 Parent(s): 1386d9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -34
app.py CHANGED
@@ -57,9 +57,16 @@ with st.sidebar:
57
  }
58
  </style>
59
  """, unsafe_allow_html=True)
60
- job_description = st.text_area("Paste the Job Description here", placeholder="Enter the job description you're applying for...", height=200, key="job_description", help="Provide the job description for matching with your resume.")
61
 
62
- # Check if user data is already in session state
 
 
 
 
 
 
 
 
63
  if "name" not in st.session_state:
64
  st.session_state["name"] = ""
65
  if "contact" not in st.session_state:
@@ -176,38 +183,21 @@ if "api_key" in st.session_state:
176
 
177
  # Cover Letter Section
178
  st.subheader("πŸ“© Generate Cover Letter")
 
 
179
 
180
- with st.form("cover_letter_form"):
181
- job_title = st.text_input("Job Title", placeholder="Enter the position you're applying for...")
182
- company_name = st.text_input("Company Name", placeholder="Enter the company name...")
183
- company_address = st.text_input("Company Address", placeholder="Enter the company's address...")
184
- cover_letter_style = st.selectbox("Choose Cover Letter Style", ("Professional", "Casual", "Creative"))
185
-
186
- submit_cover_letter = st.form_submit_button("πŸ“ Generate Cover Letter")
187
-
188
- if submit_cover_letter and job_title and company_name and company_address:
189
- # Create a prompt to generate the cover letter
190
- cover_letter_prompt = f"""
191
- Write a {cover_letter_style.lower()} cover letter for a job application.
192
-
193
- Name: {st.session_state['name']}
194
- Contact: {st.session_state['contact']}
195
- Job Title: {job_title}
196
- Company Name: {company_name}
197
- Company Address: {company_address}
198
-
199
- Cover Letter:
200
- - Begin with a greeting.
201
- - Mention the position you're applying for.
202
- - Explain why you're a good fit for the role.
203
- - Include any relevant experiences or skills.
204
- - End with a polite closing.
205
- """
206
 
207
- # Generate cover letter
208
- cover_letter_output = chat_model.invoke(input=cover_letter_prompt)
 
 
209
 
210
- # Display the cover letter and a copy button
211
- st.subheader("πŸ“© Generated Cover Letter")
212
- st.text_area("Your Cover Letter", cover_letter_output.content, height=400)
213
- st.button("πŸ“‹ Copy Cover Letter to Clipboard")
 
57
  }
58
  </style>
59
  """, unsafe_allow_html=True)
 
60
 
61
+ # Ensure the default value is fetched from session state if it exists
62
+ job_description = st.text_area("Paste the Job Description here",
63
+ placeholder="Enter the job description you're applying for...",
64
+ height=200,
65
+ key="job_description",
66
+ help="Provide the job description for matching with your resume.",
67
+ value=st.session_state.get("job_description", ""))
68
+
69
+ # Initialize other session state variables if not present
70
  if "name" not in st.session_state:
71
  st.session_state["name"] = ""
72
  if "contact" not in st.session_state:
 
183
 
184
  # Cover Letter Section
185
  st.subheader("πŸ“© Generate Cover Letter")
186
+ cover_letter_prompt = f"""
187
+ Create a cover letter for {st.session_state['name']} for the following job description:
188
 
189
+ Job Description: {st.session_state['job_description']}
190
+
191
+ Ensure the cover letter is professional and tailored to the job.
192
+ """
193
+
194
+ # Generate cover letter using ChatCohere
195
+ cover_letter_output = chat_model.invoke(input=cover_letter_prompt)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
+ # Display the generated cover letter
198
+ st.subheader("πŸ“„ Generated Cover Letter")
199
+ st.text_area("Your Cover Letter", cover_letter_output.content, height=400)
200
+ st.button("πŸ“‹ Copy Cover Letter to Clipboard")
201
 
202
+ else:
203
+ st.warning("⚠️ Please enter your details in the sidebar.")