research14 commited on
Commit
337ccf9
·
1 Parent(s): bfdd479

testing gpt response

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -89,7 +89,10 @@ def llama_respond(tab_name, message, chat_history):
89
  time.sleep(2)
90
  return tab_name, "", chat_history
91
 
92
- def gpt_strategies_respond(strategy, task_name, task_ling_ent, message, chat_history, max_convo_length = 10):
 
 
 
93
  formatted_system_prompt = ""
94
  if (task_name == "POS Tagging"):
95
  if (strategy == "S1"):
@@ -244,7 +247,7 @@ def interface():
244
  # Inputs
245
  task_prompt = gr.Textbox(show_label=False, placeholder="Write a prompt and press enter")
246
  with gr.Row():
247
- have_key = gr.Dropdown(["Yes", "No"], label="Do you own an API Key?", scale=0)
248
  task_apikey_input = gr.Textbox(label="Open AI Key", placeholder="Enter your OpenAI key here", type="password", visible=True)
249
  task = gr.Dropdown(["POS Tagging", "Chunking"], label="Task")
250
  task_linguistic_entities = gr.Dropdown(["Noun", "Determiner", "Noun phrase", "Verb phrase", "Dependent clause", "T-units"], label="Linguistic Entity For Strategy 1")
@@ -296,8 +299,8 @@ def interface():
296
  # outputs=[task, task_prompt, vicuna_S3_chatbot])
297
 
298
  # Event Handler for LLaMA Chatbot POS/Chunk
299
- task_btn.click(llama_strategies_respond, inputs=[strategy1, task, task_linguistic_entities, task_prompt, llama_S1_chatbot],
300
- outputs=[task, task_prompt, llama_S1_chatbot])
301
  # task_btn.click(llama_strategies_respond, inputs=[strategy2, task, task_linguistic_entities, task_prompt, llama_S2_chatbot],
302
  # outputs=[task, task_prompt, llama_S2_chatbot])
303
  # task_btn.click(llama_strategies_respond, inputs=[strategy3, task, task_linguistic_entities, task_prompt, llama_S3_chatbot],
@@ -306,13 +309,12 @@ def interface():
306
  # Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
307
  # Will activate after getting API key
308
  # task_apikey_btn.click(update_api_key, inputs=ling_ents_apikey_input)
309
- if (have_key.value == "Yes"):
310
- task_btn.click(gpt_strategies_respond, inputs=[strategy1, task, task_linguistic_entities, task_prompt, gpt_S1_chatbot],
311
- outputs=[task, task_prompt, gpt_S1_chatbot])
312
- task_btn.click(gpt_strategies_respond, inputs=[strategy1, task, task_linguistic_entities, task_prompt, gpt_S2_chatbot],
313
- outputs=[task, task_prompt, gpt_S2_chatbot])
314
- task_btn.click(gpt_strategies_respond, inputs=[strategy1, task, task_linguistic_entities, task_prompt, gpt_S3_chatbot],
315
- outputs=[task, task_prompt, gpt_S3_chatbot])
316
 
317
 
318
 
 
89
  time.sleep(2)
90
  return tab_name, "", chat_history
91
 
92
+ def gpt_strategies_respond(have_key, strategy, task_name, task_ling_ent, message, chat_history, max_convo_length = 10):
93
+ if (have_key == "No"):
94
+ return "", chat_history
95
+
96
  formatted_system_prompt = ""
97
  if (task_name == "POS Tagging"):
98
  if (strategy == "S1"):
 
247
  # Inputs
248
  task_prompt = gr.Textbox(show_label=False, placeholder="Write a prompt and press enter")
249
  with gr.Row():
250
+ have_key = gr.Dropdown(["Yes", "No"], label="Do you own an API Key?", scale=0.5)
251
  task_apikey_input = gr.Textbox(label="Open AI Key", placeholder="Enter your OpenAI key here", type="password", visible=True)
252
  task = gr.Dropdown(["POS Tagging", "Chunking"], label="Task")
253
  task_linguistic_entities = gr.Dropdown(["Noun", "Determiner", "Noun phrase", "Verb phrase", "Dependent clause", "T-units"], label="Linguistic Entity For Strategy 1")
 
299
  # outputs=[task, task_prompt, vicuna_S3_chatbot])
300
 
301
  # Event Handler for LLaMA Chatbot POS/Chunk
302
+ # task_btn.click(llama_strategies_respond, inputs=[strategy1, task, task_linguistic_entities, task_prompt, llama_S1_chatbot],
303
+ # outputs=[task, task_prompt, llama_S1_chatbot])
304
  # task_btn.click(llama_strategies_respond, inputs=[strategy2, task, task_linguistic_entities, task_prompt, llama_S2_chatbot],
305
  # outputs=[task, task_prompt, llama_S2_chatbot])
306
  # task_btn.click(llama_strategies_respond, inputs=[strategy3, task, task_linguistic_entities, task_prompt, llama_S3_chatbot],
 
309
  # Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
310
  # Will activate after getting API key
311
  # task_apikey_btn.click(update_api_key, inputs=ling_ents_apikey_input)
312
+ task_btn.click(gpt_strategies_respond, inputs=[have_key, strategy1, task, task_linguistic_entities, task_prompt, gpt_S1_chatbot],
313
+ outputs=[task, task_prompt, gpt_S1_chatbot])
314
+ task_btn.click(gpt_strategies_respond, inputs=[have_key, strategy1, task, task_linguistic_entities, task_prompt, gpt_S2_chatbot],
315
+ outputs=[task, task_prompt, gpt_S2_chatbot])
316
+ task_btn.click(gpt_strategies_respond, inputs=[have_key, strategy1, task, task_linguistic_entities, task_prompt, gpt_S3_chatbot],
317
+ outputs=[task, task_prompt, gpt_S3_chatbot])
 
318
 
319
 
320