Spaces:
Running
Running
yjwtheonly
commited on
Commit
·
ffb4b87
1
Parent(s):
988da9d
server
Browse files
DiseaseAgnostic/generate_abstract/random0.7_chat.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
DiseaseSpecific/generate_abstract/random_0.5_chat.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
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
|
|
Openai/chat.py
CHANGED
@@ -4,7 +4,8 @@ import os
|
|
4 |
import pandas as pd
|
5 |
import pickle as pkl
|
6 |
|
7 |
-
API_KEY = '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'
|
|
|
8 |
openai.api_key = API_KEY
|
9 |
|
10 |
def generate_abstract(prompt):
|
|
|
4 |
import pandas as pd
|
5 |
import pickle as pkl
|
6 |
|
7 |
+
# API_KEY = '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'
|
8 |
+
API_KEY = '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'
|
9 |
openai.api_key = API_KEY
|
10 |
|
11 |
def generate_abstract(prompt):
|
server.py
CHANGED
@@ -84,6 +84,8 @@ gallery_specific_text_path = 'DiseaseSpecific/generate_abstract/random_0.5_bioBA
|
|
84 |
gallery_agnostic_target_path = 'DiseaseAgnostic/processed_data/target_0.7random.pkl'
|
85 |
gallery_agnostic_link_path = 'DiseaseAgnostic/processed_data/attack_edge_distmult_0.7random.pkl'
|
86 |
gallery_agnostic_text_path = 'DiseaseAgnostic/generate_abstract/random0.7_bioBART_finetune.json'
|
|
|
|
|
87 |
gallery_specific_target = utils.load_data(gallery_specific_target_path, drop=False)
|
88 |
gallery_specific_link = utils.load_data(gallery_specific_link_path, drop=False)
|
89 |
with open(gallery_specific_text_path, 'r') as fl:
|
@@ -94,6 +96,10 @@ with open(gallery_agnostic_link_path, 'rb') as fl:
|
|
94 |
gallery_agnostic_link = pkl.load(fl)
|
95 |
with open(gallery_agnostic_text_path, 'r') as fl:
|
96 |
gallery_agnostic_text = json.load(fl)
|
|
|
|
|
|
|
|
|
97 |
|
98 |
gallery_specific_list = []
|
99 |
gallery_specific_target_dict = {}
|
@@ -710,7 +716,10 @@ def gallery_specific_func(specific_target):
|
|
710 |
o_name = entity_raw_name[id_to_entity[str(o)]]
|
711 |
|
712 |
k = f'{s}_{r}_{o}_{index}'
|
|
|
713 |
text = gallery_specific_text[k]['out']
|
|
|
|
|
714 |
return f'{capitalize_the_first_letter(s_name)} - {capitalize_the_first_letter(r_name)} - {capitalize_the_first_letter(o_name)}', server_utils.process(text)
|
715 |
|
716 |
def gallery_agnostic_func(agnostic_target):
|
@@ -720,7 +729,10 @@ def gallery_agnostic_func(agnostic_target):
|
|
720 |
r_name = Parameters.edge_id_to_type[int(r)].split(':')[1]
|
721 |
o_name = entity_raw_name[id_to_entity[str(o)]]
|
722 |
k = f'{s}_{r}_{o}_{index}'
|
|
|
723 |
text = gallery_agnostic_text[k]['out']
|
|
|
|
|
724 |
return f'{capitalize_the_first_letter(s_name)} - {capitalize_the_first_letter(r_name)} - {capitalize_the_first_letter(o_name)}', server_utils.process(text)
|
725 |
#%%
|
726 |
with gr.Blocks() as demo:
|
|
|
84 |
gallery_agnostic_target_path = 'DiseaseAgnostic/processed_data/target_0.7random.pkl'
|
85 |
gallery_agnostic_link_path = 'DiseaseAgnostic/processed_data/attack_edge_distmult_0.7random.pkl'
|
86 |
gallery_agnostic_text_path = 'DiseaseAgnostic/generate_abstract/random0.7_bioBART_finetune.json'
|
87 |
+
gallery_specific_chat_path = 'DiseaseSpecific/generate_abstract/random_0.5_chat.json'
|
88 |
+
gallery_agnostic_chat_path = 'DiseaseAgnostic/generate_abstract/random0.7_chat.json'
|
89 |
gallery_specific_target = utils.load_data(gallery_specific_target_path, drop=False)
|
90 |
gallery_specific_link = utils.load_data(gallery_specific_link_path, drop=False)
|
91 |
with open(gallery_specific_text_path, 'r') as fl:
|
|
|
96 |
gallery_agnostic_link = pkl.load(fl)
|
97 |
with open(gallery_agnostic_text_path, 'r') as fl:
|
98 |
gallery_agnostic_text = json.load(fl)
|
99 |
+
with open(gallery_specific_chat_path, 'r') as fl:
|
100 |
+
gallery_specific_chat = json.load(fl)
|
101 |
+
with open(gallery_agnostic_chat_path, 'r') as fl:
|
102 |
+
gallery_agnostic_chat = json.load(fl)
|
103 |
|
104 |
gallery_specific_list = []
|
105 |
gallery_specific_target_dict = {}
|
|
|
716 |
o_name = entity_raw_name[id_to_entity[str(o)]]
|
717 |
|
718 |
k = f'{s}_{r}_{o}_{index}'
|
719 |
+
inn = gallery_specific_text[k]['in']
|
720 |
text = gallery_specific_text[k]['out']
|
721 |
+
if inn in text:
|
722 |
+
text = gallery_specific_chat[k]['out']
|
723 |
return f'{capitalize_the_first_letter(s_name)} - {capitalize_the_first_letter(r_name)} - {capitalize_the_first_letter(o_name)}', server_utils.process(text)
|
724 |
|
725 |
def gallery_agnostic_func(agnostic_target):
|
|
|
729 |
r_name = Parameters.edge_id_to_type[int(r)].split(':')[1]
|
730 |
o_name = entity_raw_name[id_to_entity[str(o)]]
|
731 |
k = f'{s}_{r}_{o}_{index}'
|
732 |
+
inn = gallery_agnostic_text[k]['in']
|
733 |
text = gallery_agnostic_text[k]['out']
|
734 |
+
if inn in text:
|
735 |
+
text = gallery_agnostic_chat[k]['out']
|
736 |
return f'{capitalize_the_first_letter(s_name)} - {capitalize_the_first_letter(r_name)} - {capitalize_the_first_letter(o_name)}', server_utils.process(text)
|
737 |
#%%
|
738 |
with gr.Blocks() as demo:
|