tengqf commited on
Commit
b8738a2
1 Parent(s): 502e18c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -207
app.py CHANGED
@@ -1,7 +1,7 @@
1
  #!/usr/bin/env python
2
  # coding: utf-8
3
 
4
- # In[16]:
5
 
6
 
7
  import os
@@ -30,7 +30,7 @@ output_parser = CommaSeparatedListOutputParser()
30
  from datetime import datetime
31
 
32
 
33
- # In[17]:
34
 
35
 
36
 
@@ -38,14 +38,14 @@ c_splitter = CharacterTextSplitter(chunk_size = 450,chunk_overlap = 0,separator
38
  r_splitter = RecursiveCharacterTextSplitter(chunk_size = 80,chunk_overlap = 0,separators = ["\n\n"])
39
 
40
 
41
- # In[18]:
42
 
43
 
44
  output_parser = CommaSeparatedListOutputParser()
45
  format_instructions = output_parser.get_format_instructions()
46
 
47
 
48
- # In[19]:
49
 
50
 
51
  #定义常用函数
@@ -146,8 +146,8 @@ def work_exp(mock_company,mock_title,mock_skill,language,key):
146
  def club_exp(mock_soc,mock_skill_soc,language,key):
147
  club_exp_prompt = """ Write the school experience in {lang}. Considering my school experience in {club}, and I am good at {skill_sec_club}, write a part of resume for me. A good resume reorganizes the skill set in 3 examples. Each example must include 60 to 80 words. A good resume must not use pronouns. Each example must have detail numbers to describe result. List each example in a new line without serial numbers. """
148
  chat_0_4 = ChatOpenAI(temperature = 0.0,model_name = 'gpt-4',openai_api_key = key)
149
- n_range = range(0,80)
150
- rand_value = random.sample(n_range,4)
151
  print(rand_value)
152
 
153
  mock_skill_soc_fin = np.array(mock_skill_soc)[rand_value]
@@ -257,7 +257,7 @@ def resume(name,mobile,email,Gra_beg,Gra_end,Gra_sch,Gra_maj,underGra_beg,underG
257
 
258
 
259
 
260
- # In[20]:
261
 
262
 
263
  # Json输入,Dropdown更新函数
@@ -277,7 +277,7 @@ def Textbox_value(list_in,num):
277
  def Dropdown_value_rand(list_in,num):
278
  num = int(num)
279
  n_range = range(0,80)
280
- rand_value = random.sample(n_range,num)
281
  list_out = np.array(list_in)[rand_value]
282
  list_out = list_out.tolist()
283
  return list_out
@@ -299,7 +299,7 @@ with gr.Blocks() as demo:
299
  #openai_gpt4_key = gr.Textbox(label="OpenAI GPT4 Key", value="", type="password", placeholder="sk..", info = "You have to provide your own GPT4 keys for this app to function properly",)
300
  #key = str(txt_openAI_key.change(Textbox_value_submit, inputs =txt_openAI_key))
301
  #print(key)
302
- txt_key = gr.Textbox(value = "sk...",label = "key")
303
  #print(openai_gpt4_key)
304
  txt_key.change(Textbox_value_os,inputs = txt_key)
305
  txt_tarcom_in = gr.Textbox(label = "Target Company",info = "e.g. Amazon")
@@ -345,7 +345,7 @@ with gr.Blocks() as demo:
345
  exp_title_one = gr.Textbox(value = options,label="Title Name")
346
  time_beg_one = gr.Textbox(value = '2016')
347
  time_end_one = gr.Textbox(value = '2017')
348
- exp_skill_one = gr.Dropdown(value = options, label = "Skill",multiselect = True)
349
  num_one = gr.Textbox("0",visible = False)
350
  num_two = gr.Textbox("1",visible = False)
351
  num_three = gr.Textbox("2",visible = False)
@@ -358,7 +358,7 @@ with gr.Blocks() as demo:
358
  exp_txt_one_1 = gr.Textbox(value = options,interactive = True)
359
  exp_txt_one_2 = gr.Textbox(value = options,interactive = True)
360
  exp_txt_one_3 = gr.Textbox(value = options,interactive = True)
361
- btn_work_exp_one = gr.Button(value = "Update Working Experience One")
362
 
363
  btn_work_exp_one.click(work_exp, inputs=[exp_com_one,exp_title_one,exp_skill_one,txt_lang_in,txt_key],outputs = [exp_txt_one_1,exp_txt_one_2,exp_txt_one_3])
364
 
@@ -369,7 +369,7 @@ with gr.Blocks() as demo:
369
  exp_title_two = gr.Textbox(value = options,label="Title Name")
370
  time_beg_two = gr.Textbox(value = '2016')
371
  time_end_two = gr.Textbox(value = '2017')
372
- exp_skill_two = gr.Dropdown(value = options, label = "Skill",multiselect = True)
373
  btn_exp_gen.click(Textbox_value,inputs = [js_com_out,num_two],outputs = exp_com_two)
374
  btn_exp_gen.click(Textbox_value,inputs = [js_title_out,num_two],outputs = exp_title_two)
375
  btn_exp_gen.click(Dropdown_value_rand,inputs = [js_sec_skill_out,num_rand],outputs = exp_skill_two)
@@ -377,7 +377,7 @@ with gr.Blocks() as demo:
377
  exp_txt_two_1 = gr.Textbox(value = options,interactive = True)
378
  exp_txt_two_2 = gr.Textbox(value = options,interactive = True)
379
  exp_txt_two_3 = gr.Textbox(value = options,interactive = True)
380
- btn_work_exp_two = gr.Button(value = "Update Working Experience Two")
381
 
382
  btn_work_exp_two.click(work_exp, inputs=[exp_com_two,exp_title_two,exp_skill_two,txt_lang_in,txt_key],outputs = [exp_txt_two_1,exp_txt_two_2,exp_txt_two_3])
383
 
@@ -390,7 +390,7 @@ with gr.Blocks() as demo:
390
  exp_title_three = gr.Textbox(value = options,label="Title Name")
391
  time_beg_three = gr.Textbox(value = '2016')
392
  time_end_three = gr.Textbox(value = '2017')
393
- exp_skill_three = gr.Dropdown(value = options, label = "Skill",multiselect = True)
394
  btn_exp_gen.click(Textbox_value,inputs = [js_com_out,num_three],outputs = exp_com_three)
395
  btn_exp_gen.click(Textbox_value,inputs = [js_title_out,num_one],outputs = exp_title_three)
396
  btn_exp_gen.click(Dropdown_value_rand,inputs = [js_sec_skill_out,num_rand],outputs = exp_skill_three)
@@ -398,7 +398,7 @@ with gr.Blocks() as demo:
398
  exp_txt_three_1 = gr.Textbox(value = options,interactive = True)
399
  exp_txt_three_2 = gr.Textbox(value = options,interactive = True)
400
  exp_txt_three_3 = gr.Textbox(value = options,interactive = True)
401
- btn_work_exp_three = gr.Button(value = "Update Working Experience Three")
402
 
403
  btn_work_exp_three.click(work_exp, inputs=[exp_com_three,exp_title_three,exp_skill_three,txt_lang_in,txt_key],outputs = [exp_txt_three_1,exp_txt_three_2,exp_txt_three_3])
404
 
@@ -412,6 +412,7 @@ with gr.Blocks() as demo:
412
  btn_resume_gen.click(Button_visible,outputs = btn_resume_pre)
413
 
414
  webpage = gr.HTML()
 
415
 
416
  btn_resume_pre.click(resume,inputs = [name,mobile,email,Gra_beg,Gra_end,Gra_sch,Gra_maj,underGra_beg,underGra_end,underGra_sch,underGra_maj,time_beg_one,time_end_one,exp_com_one,exp_title_one,exp_txt_one_1,exp_txt_one_2,exp_txt_one_3,time_beg_two,time_end_two,exp_com_two,exp_title_two,exp_txt_two_1,exp_txt_two_2,exp_txt_two_3,time_beg_three,time_end_three,exp_com_three,exp_title_three,exp_txt_three_1,exp_txt_three_2,exp_txt_three_3],outputs = webpage)
417
 
@@ -420,198 +421,6 @@ if __name__ == "__main__":
420
  demo.launch(enable_queue = True)
421
 
422
 
423
- # In[6]:
424
-
425
-
426
-
427
-
428
-
429
- # In[31]:
430
-
431
-
432
-
433
-
434
-
435
- # In[ ]:
436
-
437
-
438
-
439
-
440
-
441
- # In[ ]:
442
-
443
-
444
-
445
-
446
-
447
- # In[ ]:
448
-
449
-
450
-
451
-
452
-
453
- # In[ ]:
454
-
455
-
456
-
457
-
458
-
459
- # In[ ]:
460
-
461
-
462
-
463
-
464
-
465
- # In[ ]:
466
-
467
-
468
-
469
-
470
-
471
- # In[ ]:
472
-
473
-
474
-
475
-
476
-
477
- # In[ ]:
478
-
479
-
480
-
481
-
482
-
483
- # In[50]:
484
-
485
-
486
-
487
-
488
-
489
- # In[ ]:
490
-
491
-
492
-
493
-
494
-
495
- # In[ ]:
496
-
497
-
498
-
499
-
500
-
501
- # In[ ]:
502
-
503
-
504
-
505
-
506
-
507
- # In[ ]:
508
-
509
-
510
-
511
-
512
-
513
- # In[ ]:
514
-
515
-
516
-
517
-
518
-
519
- # In[ ]:
520
-
521
-
522
-
523
-
524
-
525
- # In[ ]:
526
-
527
-
528
-
529
-
530
-
531
- # In[ ]:
532
-
533
-
534
-
535
-
536
-
537
- # In[ ]:
538
-
539
-
540
-
541
-
542
-
543
- # In[ ]:
544
-
545
-
546
-
547
-
548
-
549
- # In[ ]:
550
-
551
-
552
-
553
-
554
-
555
- # In[ ]:
556
-
557
-
558
-
559
-
560
-
561
- # In[ ]:
562
-
563
-
564
-
565
-
566
-
567
- # In[ ]:
568
-
569
-
570
-
571
-
572
-
573
- # In[ ]:
574
-
575
-
576
-
577
-
578
-
579
- # In[ ]:
580
-
581
-
582
-
583
-
584
-
585
- # In[ ]:
586
-
587
-
588
-
589
-
590
-
591
- # In[ ]:
592
-
593
-
594
-
595
-
596
-
597
- # In[ ]:
598
-
599
-
600
-
601
-
602
-
603
- # In[ ]:
604
-
605
-
606
-
607
-
608
-
609
- # In[ ]:
610
-
611
-
612
-
613
-
614
-
615
  # In[ ]:
616
 
617
 
 
1
  #!/usr/bin/env python
2
  # coding: utf-8
3
 
4
+ # In[1]:
5
 
6
 
7
  import os
 
30
  from datetime import datetime
31
 
32
 
33
+ # In[2]:
34
 
35
 
36
 
 
38
  r_splitter = RecursiveCharacterTextSplitter(chunk_size = 80,chunk_overlap = 0,separators = ["\n\n"])
39
 
40
 
41
+ # In[3]:
42
 
43
 
44
  output_parser = CommaSeparatedListOutputParser()
45
  format_instructions = output_parser.get_format_instructions()
46
 
47
 
48
+ # In[4]:
49
 
50
 
51
  #定义常用函数
 
146
  def club_exp(mock_soc,mock_skill_soc,language,key):
147
  club_exp_prompt = """ Write the school experience in {lang}. Considering my school experience in {club}, and I am good at {skill_sec_club}, write a part of resume for me. A good resume reorganizes the skill set in 3 examples. Each example must include 60 to 80 words. A good resume must not use pronouns. Each example must have detail numbers to describe result. List each example in a new line without serial numbers. """
148
  chat_0_4 = ChatOpenAI(temperature = 0.0,model_name = 'gpt-4',openai_api_key = key)
149
+ #n_range = range(0,80)
150
+ #rand_value = random.sample(n_range,4)
151
  print(rand_value)
152
 
153
  mock_skill_soc_fin = np.array(mock_skill_soc)[rand_value]
 
257
 
258
 
259
 
260
+ # In[12]:
261
 
262
 
263
  # Json输入,Dropdown更新函数
 
277
  def Dropdown_value_rand(list_in,num):
278
  num = int(num)
279
  n_range = range(0,80)
280
+ rand_value = np.random.randint(0,80,size = num)
281
  list_out = np.array(list_in)[rand_value]
282
  list_out = list_out.tolist()
283
  return list_out
 
299
  #openai_gpt4_key = gr.Textbox(label="OpenAI GPT4 Key", value="", type="password", placeholder="sk..", info = "You have to provide your own GPT4 keys for this app to function properly",)
300
  #key = str(txt_openAI_key.change(Textbox_value_submit, inputs =txt_openAI_key))
301
  #print(key)
302
+ txt_key = gr.Textbox(type="password", placeholder="sk..",label = "key")
303
  #print(openai_gpt4_key)
304
  txt_key.change(Textbox_value_os,inputs = txt_key)
305
  txt_tarcom_in = gr.Textbox(label = "Target Company",info = "e.g. Amazon")
 
345
  exp_title_one = gr.Textbox(value = options,label="Title Name")
346
  time_beg_one = gr.Textbox(value = '2016')
347
  time_end_one = gr.Textbox(value = '2017')
348
+ exp_skill_one = gr.Dropdown(value = options, label = "Skill",multiselect = True,visible = False)
349
  num_one = gr.Textbox("0",visible = False)
350
  num_two = gr.Textbox("1",visible = False)
351
  num_three = gr.Textbox("2",visible = False)
 
358
  exp_txt_one_1 = gr.Textbox(value = options,interactive = True)
359
  exp_txt_one_2 = gr.Textbox(value = options,interactive = True)
360
  exp_txt_one_3 = gr.Textbox(value = options,interactive = True)
361
+ btn_work_exp_one = gr.Button(value = "Update Working Experience One",visible = False)
362
 
363
  btn_work_exp_one.click(work_exp, inputs=[exp_com_one,exp_title_one,exp_skill_one,txt_lang_in,txt_key],outputs = [exp_txt_one_1,exp_txt_one_2,exp_txt_one_3])
364
 
 
369
  exp_title_two = gr.Textbox(value = options,label="Title Name")
370
  time_beg_two = gr.Textbox(value = '2016')
371
  time_end_two = gr.Textbox(value = '2017')
372
+ exp_skill_two = gr.Dropdown(value = options, label = "Skill",multiselect = True,visible = False)
373
  btn_exp_gen.click(Textbox_value,inputs = [js_com_out,num_two],outputs = exp_com_two)
374
  btn_exp_gen.click(Textbox_value,inputs = [js_title_out,num_two],outputs = exp_title_two)
375
  btn_exp_gen.click(Dropdown_value_rand,inputs = [js_sec_skill_out,num_rand],outputs = exp_skill_two)
 
377
  exp_txt_two_1 = gr.Textbox(value = options,interactive = True)
378
  exp_txt_two_2 = gr.Textbox(value = options,interactive = True)
379
  exp_txt_two_3 = gr.Textbox(value = options,interactive = True)
380
+ btn_work_exp_two = gr.Button(value = "Update Working Experience Two",visible = False)
381
 
382
  btn_work_exp_two.click(work_exp, inputs=[exp_com_two,exp_title_two,exp_skill_two,txt_lang_in,txt_key],outputs = [exp_txt_two_1,exp_txt_two_2,exp_txt_two_3])
383
 
 
390
  exp_title_three = gr.Textbox(value = options,label="Title Name")
391
  time_beg_three = gr.Textbox(value = '2016')
392
  time_end_three = gr.Textbox(value = '2017')
393
+ exp_skill_three = gr.Dropdown(value = options, label = "Skill",multiselect = True,visible = False)
394
  btn_exp_gen.click(Textbox_value,inputs = [js_com_out,num_three],outputs = exp_com_three)
395
  btn_exp_gen.click(Textbox_value,inputs = [js_title_out,num_one],outputs = exp_title_three)
396
  btn_exp_gen.click(Dropdown_value_rand,inputs = [js_sec_skill_out,num_rand],outputs = exp_skill_three)
 
398
  exp_txt_three_1 = gr.Textbox(value = options,interactive = True)
399
  exp_txt_three_2 = gr.Textbox(value = options,interactive = True)
400
  exp_txt_three_3 = gr.Textbox(value = options,interactive = True)
401
+ btn_work_exp_three = gr.Button(value = "Update Working Experience Three",visible = False)
402
 
403
  btn_work_exp_three.click(work_exp, inputs=[exp_com_three,exp_title_three,exp_skill_three,txt_lang_in,txt_key],outputs = [exp_txt_three_1,exp_txt_three_2,exp_txt_three_3])
404
 
 
412
  btn_resume_gen.click(Button_visible,outputs = btn_resume_pre)
413
 
414
  webpage = gr.HTML()
415
+ btn_resume_info.click(resume,inputs = [name,mobile,email,Gra_beg,Gra_end,Gra_sch,Gra_maj,underGra_beg,underGra_end,underGra_sch,underGra_maj,time_beg_one,time_end_one,exp_com_one,exp_title_one,exp_txt_one_1,exp_txt_one_2,exp_txt_one_3,time_beg_two,time_end_two,exp_com_two,exp_title_two,exp_txt_two_1,exp_txt_two_2,exp_txt_two_3,time_beg_three,time_end_three,exp_com_three,exp_title_three,exp_txt_three_1,exp_txt_three_2,exp_txt_three_3],outputs = webpage)
416
 
417
  btn_resume_pre.click(resume,inputs = [name,mobile,email,Gra_beg,Gra_end,Gra_sch,Gra_maj,underGra_beg,underGra_end,underGra_sch,underGra_maj,time_beg_one,time_end_one,exp_com_one,exp_title_one,exp_txt_one_1,exp_txt_one_2,exp_txt_one_3,time_beg_two,time_end_two,exp_com_two,exp_title_two,exp_txt_two_1,exp_txt_two_2,exp_txt_two_3,time_beg_three,time_end_three,exp_com_three,exp_title_three,exp_txt_three_1,exp_txt_three_2,exp_txt_three_3],outputs = webpage)
418
 
 
421
  demo.launch(enable_queue = True)
422
 
423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  # In[ ]:
425
 
426