jzou19950715 commited on
Commit
793ffff
Β·
verified Β·
1 Parent(s): 4294798

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -56
app.py CHANGED
@@ -18,17 +18,17 @@ logger = logging.getLogger(__name__) #17
18
  #18
19
  # System prompt for the AI #19
20
  SYSTEM_PROMPT = """ #20
21
- You are LOSS DOG (Life, Occupation & Student Story Digital Output Generator), an engaging and #21
22
- supportive information collector that focuses on understanding a person's complete educational #22
23
- and professional journey. Your approach is flexible, allowing both structured metrics and personal narratives. #23
24
- #24
25
- Core Traits: #25
26
- - Conversational and natural in gathering information #26
27
- - Equally values quantitative achievements and qualitative experiences #27
28
- - Adapts to each person's unique story #28
29
- - Encourages sharing of both metrics and personal growth #29
30
- - Maintains context throughout the conversation #30
31
- """ #31
32
  #32
33
  @dataclass #33
34
  class ConversationState: #34
@@ -104,7 +104,7 @@ class EducationCareerCollector: #72
104
  for attempt in range(max_retries): #104
105
  try: #105
106
  response = self.client.chat.completions.create( #106
107
- model="gpt-4", #107
108
  messages=[ #108
109
  {"role": "system", "content": SYSTEM_PROMPT}, #109
110
  *[{ #110
@@ -151,7 +151,8 @@ class EducationCareerCollector: #72
151
  "completion_status": self.get_completion_status(), #151
152
  "timestamp": datetime.now().isoformat() #152
153
  } #153
154
- def _update_conversation_state(self, ai_message: str) -> None: #154
 
155
  """Update the conversation state based on AI response.""" #155
156
  try: #156
157
  # Create analysis prompt #157
@@ -172,7 +173,7 @@ def _update_conversation_state(self, ai_message: str) -> None: #154
172
 
173
  # Get analysis from AI #164
174
  response = self.client.chat.completions.create( #165
175
- model="gpt-4", #166
176
  messages=[ #167
177
  {"role": "system", "content": SYSTEM_PROMPT}, #168
178
  *self.conversation_history, #169
@@ -274,9 +275,9 @@ def _update_conversation_state(self, ai_message: str) -> None: #154
274
 
275
  Structure the JSON naturally around the topics they shared. #249
276
  """ #250
277
- # Get initial analysis of conversation content #251
278
  analysis_response = self.client.chat.completions.create( #252
279
- model="gpt-4", #253
280
  messages=[ #254
281
  {"role": "system", "content": SYSTEM_PROMPT}, #255
282
  *self.conversation_history, #256
@@ -303,7 +304,7 @@ def _update_conversation_state(self, ai_message: str) -> None: #154
303
 
304
  # Generate the profile JSON #274
305
  profile_response = self.client.chat.completions.create( #275
306
- model="gpt-4", #276
307
  messages=[ #277
308
  {"role": "system", "content": SYSTEM_PROMPT}, #278
309
  *self.conversation_history, #279
@@ -434,7 +435,7 @@ def create_education_career_interface(): #327
434
  with gr.Row(): #388
435
  clear = gr.Button("πŸ—‘οΈ Clear Chat", scale=1) #389
436
  generate = gr.Button("πŸ“„ Generate Profile", scale=2) #390
437
- with gr.Column(scale=1): #391
438
  # Progress Information #392
439
  progress_info = gr.Markdown( #393
440
  "### Profile Progress\nStart sharing your story!", #394
@@ -456,14 +457,14 @@ with gr.Column(scale=1): #391
456
 
457
  # Tips and Guidelines #408
458
  with gr.Accordion("πŸ’‘ Tips", open=False): #409
459
- gr.Markdown(""" #410
460
- ### Share Your Story Naturally #411
461
 
462
- - Tell us about experiences that matter to you #412
463
- - Include both achievements and challenges #413
464
- - Share numbers when they're meaningful #414
465
- - Describe your growth and learning #415
466
- - Talk about what makes your journey unique #416
467
  """) #417
468
 
469
  def process_message(message: str, history: list, key: str) -> tuple: #418
@@ -565,38 +566,37 @@ with gr.Column(scale=1): #391
565
  submit.click( #498
566
  process_message, #499
567
  [msg, chatbot, api_key], #500
568
- [msg, chatbot, api_key], #501
569
- [chatbot, status_msg] #502
570
- ).then( #503
571
- update_progress, #504
572
- chatbot, #505
573
- progress_info #506
574
- ).then( #507
575
- lambda: "", #508
576
- None, #509
577
- msg #510
578
- ) #511
579
 
580
- generate.click( #512
581
- generate_profile, #513
582
- [api_key], #514
583
- [output_file, json_preview, status_msg] #515
584
- ) #516
585
 
586
- clear.click( #517
587
- clear_interface, #518
588
- None, #519
589
- [chatbot, status_msg, progress_info, json_preview, output_file] #520
590
- ) #521
591
 
592
- return demo #522
593
 
594
- if __name__ == "__main__": #523
595
- demo = create_education_career_interface() #524
596
- demo.launch( #525
597
- server_name="0.0.0.0", #526
598
- server_port=7860, #527
599
- share=True, #528
600
- enable_queue=True, #529
601
- show_error=True #530
602
- ) #531
 
18
  #18
19
  # System prompt for the AI #19
20
  SYSTEM_PROMPT = """ #20
21
+ You are LOSS DOG (Life, Occupation & Student Story Digital Output Generator), an engaging and
22
+ supportive information collector that focuses on understanding a person's complete educational
23
+ and professional journey. Your approach is flexible, allowing both structured metrics and personal narratives.
24
+
25
+ Core Traits:
26
+ - Conversational and natural in gathering information
27
+ - Equally values quantitative achievements and qualitative experiences
28
+ - Adapts to each person's unique story
29
+ - Encourages sharing of both metrics and personal growth
30
+ - Maintains context throughout the conversation
31
+ """
32
  #32
33
  @dataclass #33
34
  class ConversationState: #34
 
104
  for attempt in range(max_retries): #104
105
  try: #105
106
  response = self.client.chat.completions.create( #106
107
+ model="gpt-4o-mini", #107
108
  messages=[ #108
109
  {"role": "system", "content": SYSTEM_PROMPT}, #109
110
  *[{ #110
 
151
  "completion_status": self.get_completion_status(), #151
152
  "timestamp": datetime.now().isoformat() #152
153
  } #153
154
+
155
+ def _update_conversation_state(self, ai_message: str) -> None: #154
156
  """Update the conversation state based on AI response.""" #155
157
  try: #156
158
  # Create analysis prompt #157
 
173
 
174
  # Get analysis from AI #164
175
  response = self.client.chat.completions.create( #165
176
+ model="gpt-4o-mini", #166
177
  messages=[ #167
178
  {"role": "system", "content": SYSTEM_PROMPT}, #168
179
  *self.conversation_history, #169
 
275
 
276
  Structure the JSON naturally around the topics they shared. #249
277
  """ #250
278
+ # Get initial analysis of conversation content #251
279
  analysis_response = self.client.chat.completions.create( #252
280
+ model="gpt-4o-mini", #253
281
  messages=[ #254
282
  {"role": "system", "content": SYSTEM_PROMPT}, #255
283
  *self.conversation_history, #256
 
304
 
305
  # Generate the profile JSON #274
306
  profile_response = self.client.chat.completions.create( #275
307
+ model="gpt-4o-mini", #276
308
  messages=[ #277
309
  {"role": "system", "content": SYSTEM_PROMPT}, #278
310
  *self.conversation_history, #279
 
435
  with gr.Row(): #388
436
  clear = gr.Button("πŸ—‘οΈ Clear Chat", scale=1) #389
437
  generate = gr.Button("πŸ“„ Generate Profile", scale=2) #390
438
+ with gr.Column(scale=1): #391
439
  # Progress Information #392
440
  progress_info = gr.Markdown( #393
441
  "### Profile Progress\nStart sharing your story!", #394
 
457
 
458
  # Tips and Guidelines #408
459
  with gr.Accordion("πŸ’‘ Tips", open=False): #409
460
+ gr.Markdown("""
461
+ ### Share Your Story Naturally
462
 
463
+ - Tell us about experiences that matter to you
464
+ - Include both achievements and challenges
465
+ - Share numbers when they're meaningful
466
+ - Describe your growth and learning
467
+ - Talk about what makes your journey unique
468
  """) #417
469
 
470
  def process_message(message: str, history: list, key: str) -> tuple: #418
 
566
  submit.click( #498
567
  process_message, #499
568
  [msg, chatbot, api_key], #500
569
+ [chatbot, status_msg] #501
570
+ ).then( #502
571
+ update_progress, #503
572
+ chatbot, #504
573
+ progress_info #505
574
+ ).then( #506
575
+ lambda: "", #507
576
+ None, #508
577
+ msg #509
578
+ ) #510
 
579
 
580
+ generate.click( #511
581
+ generate_profile, #512
582
+ [api_key], #513
583
+ [output_file, json_preview, status_msg] #514
584
+ ) #515
585
 
586
+ clear.click( #516
587
+ clear_interface, #517
588
+ None, #518
589
+ [chatbot, status_msg, progress_info, json_preview, output_file] #519
590
+ ) #520
591
 
592
+ return demo #521
593
 
594
+ if __name__ == "__main__": #522
595
+ demo = create_education_career_interface() #523
596
+ demo.launch( #524
597
+ server_name="0.0.0.0", #525
598
+ server_port=7860, #526
599
+ share=True, #527
600
+ enable_queue=True, #528
601
+ show_error=True #529
602
+ ) #530