Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import json
|
2 |
import panel as pn
|
3 |
from sentrifyai import api
|
|
|
4 |
|
5 |
pn.extension(sizing_mode="stretch_width")
|
6 |
|
@@ -21,17 +22,17 @@ async def classify_emotion(message: str):
|
|
21 |
except Exception as e:
|
22 |
return json.dumps({"error": str(e)}, indent=4)
|
23 |
|
24 |
-
async def process_inputs(message: str):
|
25 |
try:
|
26 |
main.disabled = True
|
27 |
|
28 |
# Perform emotion classification
|
29 |
-
|
30 |
results = await classify_emotion(message)
|
31 |
|
32 |
# Display results
|
33 |
-
|
34 |
-
|
35 |
|
36 |
finally:
|
37 |
main.disabled = False
|
@@ -49,9 +50,8 @@ classify_button = pn.widgets.Button(name="Classify Emotion", button_type="primar
|
|
49 |
def on_button_click(event):
|
50 |
message = message_input.value
|
51 |
if message:
|
52 |
-
panel_content
|
53 |
-
|
54 |
-
pn.state.execute(async_generator, panel_content.extend)
|
55 |
|
56 |
classify_button.on_click(on_button_click)
|
57 |
|
|
|
1 |
import json
|
2 |
import panel as pn
|
3 |
from sentrifyai import api
|
4 |
+
import asyncio
|
5 |
|
6 |
pn.extension(sizing_mode="stretch_width")
|
7 |
|
|
|
22 |
except Exception as e:
|
23 |
return json.dumps({"error": str(e)}, indent=4)
|
24 |
|
25 |
+
async def process_inputs(message: str, panel_content):
|
26 |
try:
|
27 |
main.disabled = True
|
28 |
|
29 |
# Perform emotion classification
|
30 |
+
panel_content.append("##### βοΈ Classifying emotions...")
|
31 |
results = await classify_emotion(message)
|
32 |
|
33 |
# Display results
|
34 |
+
panel_content.append("##### π Emotion Classification Results:")
|
35 |
+
panel_content.append(results)
|
36 |
|
37 |
finally:
|
38 |
main.disabled = False
|
|
|
50 |
def on_button_click(event):
|
51 |
message = message_input.value
|
52 |
if message:
|
53 |
+
panel_content.clear()
|
54 |
+
asyncio.create_task(process_inputs(message, panel_content))
|
|
|
55 |
|
56 |
classify_button.on_click(on_button_click)
|
57 |
|