Spaces:
Runtime error
Runtime error
Commit
·
ce6518f
1
Parent(s):
8217779
edit lftk format
Browse files- app.py +11 -2
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import spacy
|
|
| 5 |
import time
|
| 6 |
import os
|
| 7 |
import openai
|
|
|
|
| 8 |
|
| 9 |
# Load the Vicuna 7B model and tokenizer
|
| 10 |
vicuna_tokenizer = AutoTokenizer.from_pretrained("lmsys/vicuna-7b-v1.3")
|
|
@@ -30,9 +31,11 @@ def linguistic_features_fn(message):
|
|
| 30 |
# Use LFTK to dynamically extract handcrafted linguistic features
|
| 31 |
extracted_features = LFTK.extract(features = ["a_word_ps", "a_kup_pw", "n_noun"])
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
|
| 37 |
def update_api_key(new_key):
|
| 38 |
print("update_api_key ran")
|
|
@@ -262,6 +265,7 @@ def interface():
|
|
| 262 |
|
| 263 |
ling_ents_btn.click(fn=update_textbox, inputs=ling_ents_prompt, outputs=user_prompt_1, api_name="ling_ents_btn")
|
| 264 |
|
|
|
|
| 265 |
ling_ents_btn.click(linguistic_features_fn, inputs=[ling_ents_prompt], outputs=[linguistic_features_textbox])
|
| 266 |
|
| 267 |
# Event Handler for GPT 3.5 Chatbot
|
|
@@ -320,6 +324,8 @@ def interface():
|
|
| 320 |
|
| 321 |
# Outputs
|
| 322 |
user_prompt_2 = gr.Textbox(label="Original prompt", )
|
|
|
|
|
|
|
| 323 |
gr.Markdown("### Strategy 1 - QA-Based Prompting")
|
| 324 |
strategy1 = gr.Markdown("S1", visible=False)
|
| 325 |
with gr.Row():
|
|
@@ -352,6 +358,9 @@ def interface():
|
|
| 352 |
|
| 353 |
task_btn.click(fn=update_textbox, inputs=task_prompt, outputs=user_prompt_2, api_name="task_btn")
|
| 354 |
|
|
|
|
|
|
|
|
|
|
| 355 |
# Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
|
| 356 |
# Will activate after getting API key
|
| 357 |
# task_apikey_btn.click(update_api_key, inputs=ling_ents_apikey_input)
|
|
|
|
| 5 |
import time
|
| 6 |
import os
|
| 7 |
import openai
|
| 8 |
+
import json
|
| 9 |
|
| 10 |
# Load the Vicuna 7B model and tokenizer
|
| 11 |
vicuna_tokenizer = AutoTokenizer.from_pretrained("lmsys/vicuna-7b-v1.3")
|
|
|
|
| 31 |
# Use LFTK to dynamically extract handcrafted linguistic features
|
| 32 |
extracted_features = LFTK.extract(features = ["a_word_ps", "a_kup_pw", "n_noun"])
|
| 33 |
|
| 34 |
+
formatted_output = json.dumps(extracted_features, indent=2)
|
| 35 |
|
| 36 |
+
print(formatted_output)
|
| 37 |
+
|
| 38 |
+
return formatted_output
|
| 39 |
|
| 40 |
def update_api_key(new_key):
|
| 41 |
print("update_api_key ran")
|
|
|
|
| 265 |
|
| 266 |
ling_ents_btn.click(fn=update_textbox, inputs=ling_ents_prompt, outputs=user_prompt_1, api_name="ling_ents_btn")
|
| 267 |
|
| 268 |
+
# Show features from LFTK
|
| 269 |
ling_ents_btn.click(linguistic_features_fn, inputs=[ling_ents_prompt], outputs=[linguistic_features_textbox])
|
| 270 |
|
| 271 |
# Event Handler for GPT 3.5 Chatbot
|
|
|
|
| 324 |
|
| 325 |
# Outputs
|
| 326 |
user_prompt_2 = gr.Textbox(label="Original prompt", )
|
| 327 |
+
linguistic_features_textbox_2 = gr.Textbox(label="Linguistic Features", disabled=True)
|
| 328 |
+
|
| 329 |
gr.Markdown("### Strategy 1 - QA-Based Prompting")
|
| 330 |
strategy1 = gr.Markdown("S1", visible=False)
|
| 331 |
with gr.Row():
|
|
|
|
| 358 |
|
| 359 |
task_btn.click(fn=update_textbox, inputs=task_prompt, outputs=user_prompt_2, api_name="task_btn")
|
| 360 |
|
| 361 |
+
# Show features from LFTK
|
| 362 |
+
task_btn.click(linguistic_features_fn, inputs=[task_prompt], outputs=[linguistic_features_textbox_2])
|
| 363 |
+
|
| 364 |
# Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
|
| 365 |
# Will activate after getting API key
|
| 366 |
# task_apikey_btn.click(update_api_key, inputs=ling_ents_apikey_input)
|
requirements.txt
CHANGED
|
@@ -8,4 +8,5 @@ gpt2
|
|
| 8 |
nltk
|
| 9 |
lftk
|
| 10 |
spacy
|
|
|
|
| 11 |
https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl
|
|
|
|
| 8 |
nltk
|
| 9 |
lftk
|
| 10 |
spacy
|
| 11 |
+
json
|
| 12 |
https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl
|