Spaces:
Running
Running
yjwtheonly
commited on
Commit
•
be26700
1
Parent(s):
5b98825
server
Browse files- Openai/__pycache__/chat.cpython-38.pyc +0 -0
- server.py +15 -4
Openai/__pycache__/chat.cpython-38.pyc
CHANGED
Binary files a/Openai/__pycache__/chat.cpython-38.pyc and b/Openai/__pycache__/chat.cpython-38.pyc differ
|
|
server.py
CHANGED
@@ -100,6 +100,9 @@ gallery_specific_target_dict = {}
|
|
100 |
for i, (s, r, o) in enumerate(gallery_specific_target):
|
101 |
s = id_to_meshid[str(s)]
|
102 |
o = id_to_meshid[str(o)]
|
|
|
|
|
|
|
103 |
target_name = f'{capitalize_the_first_letter(entity_raw_name[s])} - {capitalize_the_first_letter(entity_raw_name[o])}'
|
104 |
if target_name not in gallery_specific_target_dict:
|
105 |
gallery_specific_target_dict[target_name] = i
|
@@ -111,6 +114,10 @@ gallery_agnostic_target_dict = {}
|
|
111 |
|
112 |
for i, iid in enumerate(gallery_agnostic_target):
|
113 |
target_name = capitalize_the_first_letter(entity_raw_name[id_to_meshid[str(iid)]])
|
|
|
|
|
|
|
|
|
114 |
if target_name not in gallery_agnostic_target_dict:
|
115 |
gallery_agnostic_target_dict[target_name] = i
|
116 |
gallery_agnostic_list.append(target_name)
|
@@ -659,6 +666,8 @@ def specific_func(start_entity, end_entity):
|
|
659 |
|
660 |
print('Using ChatGPT for generation...')
|
661 |
draft = generate_abstract(single_sentence[0])
|
|
|
|
|
662 |
|
663 |
print('Using BioBART for tuning...')
|
664 |
span , prompt , sen_list, BART_in, Assist = tune_chatgpt([{'in':single_sentence[0], 'out': draft}], attack_data, dpath)
|
@@ -685,6 +694,8 @@ def agnostic_func(agnostic_entity):
|
|
685 |
|
686 |
print('Using ChatGPT for generation...')
|
687 |
draft = generate_abstract(single_sentence[0])
|
|
|
|
|
688 |
|
689 |
print('Using BioBART for tuning...')
|
690 |
span , prompt , sen_list, BART_in, Assist = tune_chatgpt([{'in':single_sentence[0], 'out': draft}], attack_data, dpath)
|
@@ -724,10 +735,10 @@ with gr.Blocks() as demo:
|
|
724 |
gr.Markdown("Select your poison target")
|
725 |
with gr.Tab('Gallery'):
|
726 |
with gr.Tab('Target specific'):
|
727 |
-
specific_target = gr.Dropdown(gallery_specific_list, label="
|
728 |
gallery_specific_generation_button = gr.Button('Poison!')
|
729 |
with gr.Tab('Target agnostic'):
|
730 |
-
agnostic_target = gr.Dropdown(gallery_agnostic_list, label="
|
731 |
gallery_agnostic_generation_button = gr.Button('Poison!')
|
732 |
|
733 |
with gr.Tab('Poison'):
|
@@ -743,9 +754,9 @@ with gr.Blocks() as demo:
|
|
743 |
agnostic_entity = gr.Dropdown(drug_list, label="Promoting drug")
|
744 |
agnostic_generation_button = gr.Button('Poison!')
|
745 |
with gr.Column():
|
746 |
-
gr.Markdown("
|
747 |
malicisous_link = gr.Textbox(lines=1, label="Malicious link")
|
748 |
-
gr.Markdown("Malicious text")
|
749 |
malicious_text = gr.Textbox(label="Malicious text", lines=5)
|
750 |
specific_generation_button.click(specific_func, inputs=[start_entity, end_entity], outputs=[malicisous_link, malicious_text])
|
751 |
agnostic_generation_button.click(agnostic_func, inputs=[agnostic_entity], outputs=[malicisous_link, malicious_text])
|
|
|
100 |
for i, (s, r, o) in enumerate(gallery_specific_target):
|
101 |
s = id_to_meshid[str(s)]
|
102 |
o = id_to_meshid[str(o)]
|
103 |
+
k = f'{gallery_specific_link[i][0]}_{gallery_specific_link[i][1]}_{gallery_specific_link[i][2]}_{i}'
|
104 |
+
if 'sorry' in gallery_specific_text[k]['out'] or 'Sorry' in gallery_specific_text[k]['out']:
|
105 |
+
continue
|
106 |
target_name = f'{capitalize_the_first_letter(entity_raw_name[s])} - {capitalize_the_first_letter(entity_raw_name[o])}'
|
107 |
if target_name not in gallery_specific_target_dict:
|
108 |
gallery_specific_target_dict[target_name] = i
|
|
|
114 |
|
115 |
for i, iid in enumerate(gallery_agnostic_target):
|
116 |
target_name = capitalize_the_first_letter(entity_raw_name[id_to_meshid[str(iid)]])
|
117 |
+
|
118 |
+
k = f'{gallery_agnostic_link[i][0]}_{gallery_agnostic_link[i][1]}_{gallery_agnostic_link[i][2]}_{i}'
|
119 |
+
if 'sorry' in gallery_agnostic_text[k]['out'] or 'Sorry' in gallery_agnostic_text[k]['out']:
|
120 |
+
continue
|
121 |
if target_name not in gallery_agnostic_target_dict:
|
122 |
gallery_agnostic_target_dict[target_name] = i
|
123 |
gallery_agnostic_list.append(target_name)
|
|
|
666 |
|
667 |
print('Using ChatGPT for generation...')
|
668 |
draft = generate_abstract(single_sentence[0])
|
669 |
+
if 'sorry' in draft or 'Sorry' in draft:
|
670 |
+
return 'All candidate links are filterd out by defender, so no malicious link can be generated', 'No malicious abstract can be generated'
|
671 |
|
672 |
print('Using BioBART for tuning...')
|
673 |
span , prompt , sen_list, BART_in, Assist = tune_chatgpt([{'in':single_sentence[0], 'out': draft}], attack_data, dpath)
|
|
|
694 |
|
695 |
print('Using ChatGPT for generation...')
|
696 |
draft = generate_abstract(single_sentence[0])
|
697 |
+
if 'sorry' in draft or 'Sorry' in draft:
|
698 |
+
return 'All candidate links are filterd out by defender, so no malicious link can be generated', 'No malicious abstract can be generated'
|
699 |
|
700 |
print('Using BioBART for tuning...')
|
701 |
span , prompt , sen_list, BART_in, Assist = tune_chatgpt([{'in':single_sentence[0], 'out': draft}], attack_data, dpath)
|
|
|
735 |
gr.Markdown("Select your poison target")
|
736 |
with gr.Tab('Gallery'):
|
737 |
with gr.Tab('Target specific'):
|
738 |
+
specific_target = gr.Dropdown(gallery_specific_list, label="Promoting drug and target disease")
|
739 |
gallery_specific_generation_button = gr.Button('Poison!')
|
740 |
with gr.Tab('Target agnostic'):
|
741 |
+
agnostic_target = gr.Dropdown(gallery_agnostic_list, label="Promoting drug")
|
742 |
gallery_agnostic_generation_button = gr.Button('Poison!')
|
743 |
|
744 |
with gr.Tab('Poison'):
|
|
|
754 |
agnostic_entity = gr.Dropdown(drug_list, label="Promoting drug")
|
755 |
agnostic_generation_button = gr.Button('Poison!')
|
756 |
with gr.Column():
|
757 |
+
gr.Markdown("Generation")
|
758 |
malicisous_link = gr.Textbox(lines=1, label="Malicious link")
|
759 |
+
# gr.Markdown("Malicious text")
|
760 |
malicious_text = gr.Textbox(label="Malicious text", lines=5)
|
761 |
specific_generation_button.click(specific_func, inputs=[start_entity, end_entity], outputs=[malicisous_link, malicious_text])
|
762 |
agnostic_generation_button.click(agnostic_func, inputs=[agnostic_entity], outputs=[malicisous_link, malicious_text])
|