jzou19950715 commited on
Commit
6f7169e
·
verified ·
1 Parent(s): cd17259

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -83,7 +83,7 @@ def analyze_resume_with_lossdog(
83
  response = openai.ChatCompletion.create(
84
  model="gpt-4o-mini",
85
  messages=messages,
86
- max_tokens=50000,
87
  )
88
  assistant_response = response.choices[0].message.content
89
  history.append({"role": "assistant", "content": assistant_response})
@@ -119,9 +119,10 @@ def create_demo():
119
  # 🐕 LOSS Dog: AI-Powered Resume Analyzer
120
 
121
  Upload your resume (PDF or TXT), and Loss Dog will:
122
- 1. Convert it to Markdown for readability.
123
- 2. Analyze it and start a conversation to improve it.
124
- 3. Help you build a polished JSON summary.
 
125
  """)
126
 
127
  with gr.Row():
@@ -133,6 +134,7 @@ def create_demo():
133
 
134
  with gr.Row():
135
  upload = gr.File(label="Upload Your Resume (PDF or TXT)")
 
136
 
137
  markdown_preview = gr.Markdown(label="Resume Content (Markdown)")
138
  chatbot = gr.Chatbot(label="Chat with LOSS Dog", type="messages")
@@ -152,21 +154,27 @@ def create_demo():
152
 
153
  def handle_upload(file, api_key):
154
  if not file:
155
- return None, "No file uploaded.", [], None
156
 
157
  file_path = file.name
158
  file_content = extract_text_from_file(file_path, file.name)
159
  if "Error" in file_content:
160
- return None, file_content, [], None
 
 
 
 
 
161
 
162
  markdown_text = convert_to_markdown(file_content)
163
  history = [
164
  {
165
  "role": "assistant",
166
- "content": "I've read your resume. Let's analyze it! What would you like to discuss first?",
167
  }
168
  ]
169
- return file, markdown_text, history, markdown_text
 
170
 
171
  def handle_message(message, api_key, history, markdown_text):
172
  if not message.strip():
@@ -174,14 +182,10 @@ def create_demo():
174
 
175
  return analyze_resume_with_lossdog(markdown_text, api_key, history)
176
 
177
- def handle_generate_json(history):
178
- filename, json_content = generate_json_output(history)
179
- return json_content
180
-
181
  upload.change(
182
  handle_upload,
183
  inputs=[upload, api_key],
184
- outputs=[upload, markdown_preview, chatbot, markdown_state]
185
  )
186
 
187
  send_button.click(
 
83
  response = openai.ChatCompletion.create(
84
  model="gpt-4o-mini",
85
  messages=messages,
86
+ max_tokens=4096, # Increased token limit to the maximum
87
  )
88
  assistant_response = response.choices[0].message.content
89
  history.append({"role": "assistant", "content": assistant_response})
 
119
  # 🐕 LOSS Dog: AI-Powered Resume Analyzer
120
 
121
  Upload your resume (PDF or TXT), and Loss Dog will:
122
+ 1. Display a preview of the original PDF.
123
+ 2. Convert it to Markdown for readability.
124
+ 3. Proactively analyze it and start a conversation.
125
+ 4. Help you build a polished JSON summary.
126
  """)
127
 
128
  with gr.Row():
 
134
 
135
  with gr.Row():
136
  upload = gr.File(label="Upload Your Resume (PDF or TXT)")
137
+ pdf_preview = gr.Preview(label="PDF Preview (for PDFs)")
138
 
139
  markdown_preview = gr.Markdown(label="Resume Content (Markdown)")
140
  chatbot = gr.Chatbot(label="Chat with LOSS Dog", type="messages")
 
154
 
155
  def handle_upload(file, api_key):
156
  if not file:
157
+ return None, None, "No file uploaded.", [], None
158
 
159
  file_path = file.name
160
  file_content = extract_text_from_file(file_path, file.name)
161
  if "Error" in file_content:
162
+ return None, None, file_content, [], None
163
+
164
+ if file.name.endswith(".pdf"):
165
+ pdf_path = file.name
166
+ else:
167
+ pdf_path = None
168
 
169
  markdown_text = convert_to_markdown(file_content)
170
  history = [
171
  {
172
  "role": "assistant",
173
+ "content": "I've read your resume. Let's analyze it! Here are some observations.",
174
  }
175
  ]
176
+ history = analyze_resume_with_lossdog(markdown_text, api_key, history)
177
+ return file, pdf_path, markdown_text, history, markdown_text
178
 
179
  def handle_message(message, api_key, history, markdown_text):
180
  if not message.strip():
 
182
 
183
  return analyze_resume_with_lossdog(markdown_text, api_key, history)
184
 
 
 
 
 
185
  upload.change(
186
  handle_upload,
187
  inputs=[upload, api_key],
188
+ outputs=[upload, pdf_preview, markdown_preview, chatbot, markdown_state]
189
  )
190
 
191
  send_button.click(