Spaces:
Runtime error
Runtime error
Commit
·
e1ba54a
1
Parent(s):
61dbd3b
testing gpt generation
Browse files
app.py
CHANGED
@@ -88,30 +88,31 @@ def llama_respond(tab_name, message, chat_history):
|
|
88 |
time.sleep(2)
|
89 |
return tab_name, "", chat_history
|
90 |
|
91 |
-
def gpt_strategies_respond(strategy, task_name, task_ling_ent, message, chat_history, max_convo_length = 10):
|
92 |
-
|
93 |
-
|
94 |
-
if (
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
115 |
|
116 |
def vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_history):
|
117 |
formatted_prompt = ""
|
@@ -303,13 +304,12 @@ def interface():
|
|
303 |
# Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
|
304 |
# Will activate after getting API key
|
305 |
# task_apikey_btn.click(update_api_key, inputs=ling_ents_apikey_input)
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
outputs=[task, task_prompt, gpt_S3_chatbot])
|
313 |
|
314 |
|
315 |
|
|
|
88 |
time.sleep(2)
|
89 |
return tab_name, "", chat_history
|
90 |
|
91 |
+
def gpt_strategies_respond(have_key, strategy, task_name, task_ling_ent, message, chat_history, max_convo_length = 10):
|
92 |
+
if (have_key == "Yes"):
|
93 |
+
formatted_system_prompt = ""
|
94 |
+
if (task_name == "POS Tagging"):
|
95 |
+
if (strategy == "S1"):
|
96 |
+
formatted_system_prompt = f'''Generate the output only for the assistant. Output any {task_ling_ent} in the following sentence one per line without any additional text: {message}'''
|
97 |
+
elif (strategy == "S2"):
|
98 |
+
formatted_system_prompt = f'''POS tag the following sentence using Universal POS tag set without generating any additional text: {message}'''
|
99 |
+
elif (strategy == "S3"):
|
100 |
+
formatted_system_prompt = f'''POS tag the following sentence using Universal POS tag set without generating any additional text: {message}'''
|
101 |
+
elif (task_name == "Chunking"):
|
102 |
+
if (strategy == "S1"):
|
103 |
+
formatted_system_prompt = f'''Generate the output only for the assistant. Output any {task_ling_ent} in the following sentence one per line without any additional text: {message}'''
|
104 |
+
elif (strategy == "S2"):
|
105 |
+
formatted_system_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags without outputing any additional text: {message}'''
|
106 |
+
elif (strategy == "S3"):
|
107 |
+
formatted_system_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags without outputing any additional text: {message}'''
|
108 |
+
|
109 |
+
formatted_prompt = format_chat_prompt(message, chat_history, max_convo_length)
|
110 |
+
print('Prompt + Context:')
|
111 |
+
print(formatted_prompt)
|
112 |
+
bot_message = chat(system_prompt = formatted_system_prompt,
|
113 |
+
user_prompt = formatted_prompt)
|
114 |
+
chat_history.append((message, bot_message))
|
115 |
+
return "", chat_history
|
116 |
|
117 |
def vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_history):
|
118 |
formatted_prompt = ""
|
|
|
304 |
# Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
|
305 |
# Will activate after getting API key
|
306 |
# task_apikey_btn.click(update_api_key, inputs=ling_ents_apikey_input)
|
307 |
+
task_btn.click(gpt_strategies_respond, inputs=[have_key, strategy1, task, task_linguistic_entities, gpt_S1_chatbot],
|
308 |
+
outputs=[task, task_prompt, gpt_S1_chatbot])
|
309 |
+
task_btn.click(gpt_strategies_respond, inputs=[have_key, strategy1, task, task_linguistic_entities, gpt_S2_chatbot],
|
310 |
+
outputs=[task, task_prompt, gpt_S2_chatbot])
|
311 |
+
task_btn.click(gpt_strategies_respond, inputs=[have_key, strategy1, task, task_linguistic_entities, gpt_S3_chatbot],
|
312 |
+
outputs=[task, task_prompt, gpt_S3_chatbot])
|
|
|
313 |
|
314 |
|
315 |
|