Spaces:
Runtime error
Runtime error
Commit
•
7f7f814
1
Parent(s):
9297ec9
Update app.py
Browse files
app.py
CHANGED
@@ -33,36 +33,38 @@ new_emotions_prompt = [
|
|
33 |
]
|
34 |
|
35 |
import os
|
36 |
-
|
37 |
-
import
|
38 |
-
from
|
39 |
|
40 |
def emo(name, temper, save_response):
|
41 |
-
prompters =
|
42 |
response_text = prompters.prompt_model_print(new_emotions_prompt)
|
43 |
if save_response:
|
44 |
-
|
|
|
45 |
|
46 |
def save_emotion_output(response_text):
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
print("Saved emotion output to emotion_output.
|
51 |
|
52 |
with gr.Blocks() as demo:
|
53 |
with gr.Row():
|
54 |
-
slider = gr.Slider(0, 1, label=
|
55 |
info="Choose a float value between 0 and 1 to set the 'creativity' "
|
56 |
-
|
57 |
-
|
58 |
emo_out = gr.Textbox(value='text', label="Output", lines=3)
|
59 |
#save_btn = gr.Button(label="Save Emotion")
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
-
if __name__ == "__main__":
|
67 |
-
demo.launch()
|
68 |
|
|
|
33 |
]
|
34 |
|
35 |
import os
|
36 |
+
|
37 |
+
from google.colab import files
|
38 |
+
from google.colab import drive
|
39 |
|
40 |
def emo(name, temper, save_response):
|
41 |
+
prompters = Prompter("gpt-3.5-turbo", temper)
|
42 |
response_text = prompters.prompt_model_print(new_emotions_prompt)
|
43 |
if save_response:
|
44 |
+
save_response_to_file(response_text)
|
45 |
+
return response_text
|
46 |
|
47 |
def save_emotion_output(response_text):
|
48 |
+
with open("/content/drive/MyDrive/emotion_output.html", "a") as file:
|
49 |
+
file.write(response_text)
|
50 |
+
file.write("\n")
|
51 |
+
print("Saved emotion output to emotion_output.html")
|
52 |
|
53 |
with gr.Blocks() as demo:
|
54 |
with gr.Row():
|
55 |
+
slider = gr.Slider(0, 1, label='Temperature',
|
56 |
info="Choose a float value between 0 and 1 to set the 'creativity' "
|
57 |
+
"of the machine. Keep in mind that a value of 1 (highest) may create inconsistent "
|
58 |
+
"but also interesting results.")
|
59 |
emo_out = gr.Textbox(value='text', label="Output", lines=3)
|
60 |
#save_btn = gr.Button(label="Save Emotion")
|
61 |
+
with gr.Row():
|
62 |
+
btn = gr.Button(value="Generate Emotion")
|
63 |
+
btn.click(emo, inputs=slider, outputs = emo_out)
|
64 |
+
save_btn = gr.Button(value="Save Emotion")
|
65 |
+
save_btn.click(save_emotion_output, inputs=emo_out)
|
66 |
+
|
67 |
+
if __name__ == "__main__":
|
68 |
+
demo.launch()
|
69 |
|
|
|
|
|
70 |
|