research14 commited on
Commit
f0030c7
Β·
1 Parent(s): 0ce110a

added corenlp tab

Browse files
Files changed (1) hide show
  1. app.py +59 -1
app.py CHANGED
@@ -47,7 +47,10 @@ def format_chat_prompt(message, chat_history, max_convo_length):
47
  prompt = f"{prompt}\nUser: {message}\nAssistant:"
48
  return prompt
49
 
50
- def gpt_respond(tab_name, message, chat_history, max_convo_length = 10):
 
 
 
51
  formatted_prompt = format_chat_prompt(message, chat_history, max_convo_length)
52
  print('Prompt + Context:')
53
  print(formatted_prompt)
@@ -183,6 +186,61 @@ def llama_strategies_respond(strategy, task_name, task_ling_ent, message, chat_h
183
 
184
  def interface():
185
  with gr.Tab("Linguistic Entities"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  gr.Markdown("""
187
  ## πŸ“œ Step-By-Step Instructions
188
 
 
47
  prompt = f"{prompt}\nUser: {message}\nAssistant:"
48
  return prompt
49
 
50
+ def gpt_respond(have_key, tab_name, message, chat_history, max_convo_length = 10):
51
+ if (have_key == "No"):
52
+ return "", chat_history
53
+
54
  formatted_prompt = format_chat_prompt(message, chat_history, max_convo_length)
55
  print('Prompt + Context:')
56
  print(formatted_prompt)
 
186
 
187
  def interface():
188
  with gr.Tab("Linguistic Entities"):
189
+ gr.Markdown("""
190
+ ## πŸ“œ Step-By-Step Instructions
191
+
192
+ - Enter a sentence for three models to process (Vicuna-7b, LLaMA-7b and GPT-3.5).
193
+ - If you own an OpenAI API key, select 'Yes' in the dropdown. If you don't own one, select 'No'.
194
+ - If you selected 'Yes', enter your OpenAI API Key [Link to your OpenAI keys](https://platform.openai.com/api-keys).
195
+ - If you selected 'No', leave the 'OpenAI Key' field blank and continue with the rest.
196
+ - Select a Linguistic Entity from the Dropdown.
197
+ - Click 'Submit' to send your inputs to the models.
198
+ - To enter a new prompt, scroll to the bottom and click 'Clear' to start again.
199
+
200
+ ### ⏳ After you click 'Submit', the models will take a couple seconds to process your inputs.
201
+ ### πŸ€– Then, the models will output the linguistic entity found in your prompt based on your selection!
202
+
203
+ Note: If you get an 'Error' in the gpt-3.5 model, check the following:
204
+ - Check that you entered your key correctly without any extra characters.
205
+ - If you used a free key, it means you exceeded your quota from the free API Key.
206
+ """)
207
+
208
+ # Inputs
209
+ ling_ents_prompt = gr.Textbox(show_label=False, placeholder="Write a prompt and press enter")
210
+ with gr.Row():
211
+ # Will activate after getting API key
212
+ have_key2 = gr.Dropdown(["Yes", "No"], label="Do you own an API Key?", scale=0.5)
213
+ ling_ents_apikey_input = gr.Textbox(label="Open AI Key", placeholder="Enter your Openai key here", type="password")
214
+ linguistic_entities = gr.Dropdown(["Noun", "Determiner", "Noun phrase", "Verb phrase", "Dependent clause", "T-units"], label="Linguistic Entity")
215
+ ling_ents_btn = gr.Button(value="Submit")
216
+
217
+ # Outputs
218
+ gr.Markdown("Strategy 1 QA-Based Prompting")
219
+
220
+ # linguistic_features_textbox = gr.Textbox(label="Linguistic Features", disabled=True)
221
+
222
+ with gr.Row():
223
+ gpt_ling_ents_chatbot = gr.Chatbot(label="gpt-3.5")
224
+ llama_ling_ents_chatbot = gr.Chatbot(label="llama-7b")
225
+ vicuna_ling_ents_chatbot = gr.Chatbot(label="vicuna-7b")
226
+ clear = gr.ClearButton(components=[ling_ents_prompt, ling_ents_apikey_input, vicuna_ling_ents_chatbot, llama_ling_ents_chatbot, gpt_ling_ents_chatbot])
227
+
228
+ # Event Handler for API Key
229
+ ling_ents_btn.click(update_api_key, inputs=ling_ents_apikey_input)
230
+
231
+ # Event Handler for GPT 3.5 Chatbot
232
+ ling_ents_btn.click(gpt_respond, inputs=[have_key2, linguistic_entities, ling_ents_prompt, gpt_ling_ents_chatbot],
233
+ outputs=[task_prompt, gpt_ling_ents_chatbot])
234
+
235
+ # Event Handler for LLaMA Chatbot
236
+ ling_ents_btn.click(llama_respond, inputs=[linguistic_entities, ling_ents_prompt, llama_ling_ents_chatbot],
237
+ outputs=[linguistic_entities, ling_ents_prompt, llama_ling_ents_chatbot])
238
+
239
+ # Event Handler for Vicuna Chatbot
240
+ ling_ents_btn.click(vicuna_respond, inputs=[linguistic_entities, ling_ents_prompt, vicuna_ling_ents_chatbot],
241
+ outputs=[linguistic_entities, ling_ents_prompt, vicuna_ling_ents_chatbot])
242
+
243
+ with gr.Tab("CoreNLP"):
244
  gr.Markdown("""
245
  ## πŸ“œ Step-By-Step Instructions
246