Spaces:
Build error
Build error
Commit
·
3f89845
1
Parent(s):
3de0eaa
Imorove ui
Browse files
app.py
CHANGED
@@ -8,12 +8,13 @@ def run_prompt(prompt, api_key, model_name, max_length):
|
|
8 |
lemmatized_prompt = lemmatizer_func(prompt)
|
9 |
response_plain = prompt_node(prompt)
|
10 |
response_lemmatized = prompt_node(lemmatized_prompt)
|
11 |
-
return response_plain[0][0], response_plain[1]["
|
12 |
|
13 |
with gr.Blocks() as demo:
|
14 |
with gr.Row():
|
15 |
api_key = gr.Textbox(label="Enter your api key")
|
16 |
model_name = gr.Dropdown(["text-davinci-003", "gpt-3.5-turbo", "gpt-4", "gpt-4-32k", "command", "command-light", "base", "base-light"], value="gpt-3.5-turbo", label="Choose your model!")
|
|
|
17 |
with gr.Row():
|
18 |
prompt = gr.TextArea(label="Prompt", value="Rachel has 17 apples. She gives 9 to Sarah. How many apples does Rachel have now?")
|
19 |
gr.Examples(
|
@@ -26,16 +27,20 @@ with gr.Blocks() as demo:
|
|
26 |
],
|
27 |
inputs=prompt,
|
28 |
label="Click on any example and press Enter in the input textbox!",
|
29 |
-
)
|
30 |
-
max_length = gr.Slider(100, 500, value=100, step=10, label="Max Length", info="Choose between 100 and 500")
|
31 |
submit_btn = gr.Button("Submit")
|
32 |
with gr.Row():
|
33 |
prompt_response = gr.TextArea(label="Answer", show_copy_button=True)
|
34 |
-
|
|
|
|
|
35 |
with gr.Row():
|
36 |
lemmatized_prompt_response = gr.TextArea(label="Lemmatized Answer", show_copy_button=True)
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
|
40 |
demo.launch()
|
41 |
|
|
|
8 |
lemmatized_prompt = lemmatizer_func(prompt)
|
9 |
response_plain = prompt_node(prompt)
|
10 |
response_lemmatized = prompt_node(lemmatized_prompt)
|
11 |
+
return lemmatized_prompt, response_plain[0][0], response_plain[1]["prompt_tokens"], response_plain[1]["completion_tokens"], response_lemmatized[0][0], response_lemmatized[1]["prompt_tokens"], response_lemmatized[1]["completion_tokens"]
|
12 |
|
13 |
with gr.Blocks() as demo:
|
14 |
with gr.Row():
|
15 |
api_key = gr.Textbox(label="Enter your api key")
|
16 |
model_name = gr.Dropdown(["text-davinci-003", "gpt-3.5-turbo", "gpt-4", "gpt-4-32k", "command", "command-light", "base", "base-light"], value="gpt-3.5-turbo", label="Choose your model!")
|
17 |
+
max_length = gr.Slider(100, 500, value=100, step=10, label="Max Length", info="Max token length of the response. Choose between 100 and 500")
|
18 |
with gr.Row():
|
19 |
prompt = gr.TextArea(label="Prompt", value="Rachel has 17 apples. She gives 9 to Sarah. How many apples does Rachel have now?")
|
20 |
gr.Examples(
|
|
|
27 |
],
|
28 |
inputs=prompt,
|
29 |
label="Click on any example and press Enter in the input textbox!",
|
30 |
+
)
|
|
|
31 |
submit_btn = gr.Button("Submit")
|
32 |
with gr.Row():
|
33 |
prompt_response = gr.TextArea(label="Answer", show_copy_button=True)
|
34 |
+
with gr.Column():
|
35 |
+
token_count_plain = gr.Number(label="Prompt Token Count")
|
36 |
+
token_count_plain_completion = gr.Number(label="Completion Token Count")
|
37 |
with gr.Row():
|
38 |
lemmatized_prompt_response = gr.TextArea(label="Lemmatized Answer", show_copy_button=True)
|
39 |
+
with gr.Column():
|
40 |
+
lemmatized_prompt = gr.TextArea(label="Lemmatized Promp", show_copy_button=True)
|
41 |
+
token_count_lemmatized = gr.Number(label="Lemmatized Text Token Count")
|
42 |
+
token_count_lemmatized_completion = gr.Number(label="Completion Lemmatized Token Count")
|
43 |
+
submit_btn.click(fn=run_prompt, inputs=[prompt, api_key, model_name, max_length], outputs=[lemmatized_prompt, prompt_response, token_count_plain, token_count_plain_completion, lemmatized_prompt_response, token_count_lemmatized, token_count_lemmatized_completion])
|
44 |
|
45 |
demo.launch()
|
46 |
|
utils.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from simplemma import text_lemmatizer
|
2 |
|
3 |
def lemmatizer_func(plain_text):
|
4 |
-
|
5 |
-
lemmatized_promt = ' '.join(words)
|
6 |
return lemmatized_promt
|
|
|
1 |
from simplemma import text_lemmatizer
|
2 |
|
3 |
def lemmatizer_func(plain_text):
|
4 |
+
lemmatized_promt = ' '.join([el for el in text_lemmatizer(plain_text, lang='en') if el.isalnum()])
|
|
|
5 |
return lemmatized_promt
|