@@ -126,7 +126,6 @@ def config():
126
126
127
127
def call_gpt (paragraph , trigger ):
128
128
# openai.api_key = os.environ.get("GPT-API")
129
- openai .api_key = ""
130
129
tokenizer = BartTokenizer .from_pretrained ("theQuert/NetKUp-tokenzier" )
131
130
inputs_for_gpt = f"""
132
131
s an article writer, your task is to provide an updated paragraph in the length same as non-updated paragraph based on the given non-updated paragraph and a triggered news.Remember, the length of updated paragraph is restricted into a single paragraph.
@@ -160,13 +159,13 @@ def call_vicuna(paragraphs_tirgger):
160
159
{ trigger }
161
160
"""
162
161
merged_with_prompts .append (merged .strip ())
163
- pd .DataFrame ({"paragraph" : merged_with_prompts }).to_csv ("./experiments/paragraphs_with_prompts.csv" )
162
+ pd .DataFrame ({"paragraph" : merged_with_prompts }).to_csv ("./util/ experiments/paragraphs_with_prompts.csv" )
164
163
responses = vicuna_output ()
165
164
return responses
166
165
167
166
168
167
def main (input_article , input_trigger ):
169
- paths = [".util/experiments/input_paragraphs.csv" ,
168
+ paths = [".util/experiments/input_paragraphs.csv" ,
170
169
"./util/experiments/formatted_input.txt" ,
171
170
"./util/experiments/updated_article.txt" ,
172
171
"./util/experiments/paragraphs_needed.txt" ,
@@ -275,23 +274,23 @@ def main(input_article, input_trigger):
275
274
# paragarphs_merged = ["".join(par.split(" -- ")[:-1]) for par in paragraphs_merged]
276
275
updated_article = str (sep .join (paragraphs_merged ))
277
276
updated_article = updated_article .replace ("[{'summary_text': '" , "" ).replace ("'}]" , "" ).strip ()
278
- class_res = pd .read_csv ("./experiments/classification.csv" )
277
+ class_res = pd .read_csv ("./util/ experiments/classification.csv" )
279
278
if class_res .target .values .all () == 0 : modified = "False"
280
279
281
280
if len (data_test )== 1 :
282
281
modified = "TRUE"
283
282
updated_article = call_gpt (input_article , input_trigger )
284
- with open ("./experiments/updated_article.txt" , "w" ) as f :
283
+ with open ("./util/ experiments/updated_article.txt" , "w" ) as f :
285
284
f .write (updated_article )
286
285
287
286
# combine the predictions and paragraphs into csv format file
288
- merged_par_pred_df = pd .DataFrame ({"paragraphs" : data_test , "predictions" : predictions }).to_csv ("./experiments/par_with_class.csv" )
287
+ merged_par_pred_df = pd .DataFrame ({"paragraphs" : data_test , "predictions" : predictions }).to_csv ("./util/ experiments/par_with_class.csv" )
289
288
# return updated_article, modified, merged_par_pred_df
290
289
modified_in_all = str (len (paragraphs_needed )) + " / " + str (len (data_test ))
291
290
return updated_article , modified_in_all
292
291
293
292
def copy_to_clipboard (t ):
294
- with open ("./experiments/updated_article.txt" , "r" ) as f :
293
+ with open ("./util/ experiments/updated_article.txt" , "r" ) as f :
295
294
t = f .read ()
296
295
pyperclip .copy (t )
297
296
@@ -369,5 +368,5 @@ def compare_versions():
369
368
"""
370
369
)
371
370
372
- demo .launch ()
371
+ demo .launch (server_name = "0.0.0.0" , server_port = 7840 )
373
372
0 commit comments