Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,7 +40,12 @@ def respond(
|
|
| 40 |
):
|
| 41 |
token = message.choices[0].delta.content
|
| 42 |
response += token
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
"""
|
|
@@ -50,43 +55,38 @@ demo = gr.ChatInterface(
|
|
| 50 |
respond,
|
| 51 |
additional_inputs=[
|
| 52 |
gr.Textbox(
|
| 53 |
-
value="You are tasked with labeling text data based on both emotion temperature and text type categories. The final output must be a 13-character code that consists of the following structure"
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
- If the emotion is purely
|
| 57 |
-
- If the emotion is purely
|
| 58 |
-
- If the emotion is
|
| 59 |
-
|
| 60 |
-
-
|
| 61 |
-
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
The output would be: CW02305000010
|
| 87 |
-
|
| 88 |
-
Output Format:
|
| 89 |
-
Always return a 13-character code following this structure.""",
|
| 90 |
lines=10,
|
| 91 |
),
|
| 92 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
|
|
| 40 |
):
|
| 41 |
token = message.choices[0].delta.content
|
| 42 |
response += token
|
| 43 |
+
|
| 44 |
+
# Validate the response format
|
| 45 |
+
if len(response) == 13 and all(c.isdigit() or c in 'CW' for c in response):
|
| 46 |
+
return response
|
| 47 |
+
else:
|
| 48 |
+
return "Invalid response format"
|
| 49 |
|
| 50 |
|
| 51 |
"""
|
|
|
|
| 55 |
respond,
|
| 56 |
additional_inputs=[
|
| 57 |
gr.Textbox(
|
| 58 |
+
value="You are tasked with labeling text data based on both emotion temperature and text type categories. The final output must be a 13-character code that consists of the following structure:\n\n"
|
| 59 |
+
"1. Emotion Temperature Code (2 characters):\n"
|
| 60 |
+
" - If the emotion is purely Cold: Use CC\n"
|
| 61 |
+
" - If the emotion is purely Warm: Use WW\n"
|
| 62 |
+
" - If the emotion is purely Hot: Use HH\n"
|
| 63 |
+
" - If the emotion is a mix, use one of the following:\n"
|
| 64 |
+
" - Cold and Warm: Use CW\n"
|
| 65 |
+
" - Warm and Hot: Use WH\n"
|
| 66 |
+
" - Cold and Hot: Use CH\n\n"
|
| 67 |
+
"2. Text Type Codes (next 9 digits):\n"
|
| 68 |
+
" Assign a digit for each of the following categories based on the presence in the text. Use 0 for categories not applicable:\n"
|
| 69 |
+
" 1: Toxic\n"
|
| 70 |
+
" 2: Appreciation\n"
|
| 71 |
+
" 3: Constructive Criticism\n"
|
| 72 |
+
" 4: Genuine Questions\n"
|
| 73 |
+
" 5: Advice/Suggestions\n"
|
| 74 |
+
" 6: Requests\n"
|
| 75 |
+
" 7: Spam\n"
|
| 76 |
+
" 8: Off-Topic\n"
|
| 77 |
+
" 9: Engagement Boosters\n\n"
|
| 78 |
+
"3. Special Categories (last 2 digits):\n"
|
| 79 |
+
" If the text is Neutral/General: Set the 10th digit to 1; otherwise, set it to 0.\n"
|
| 80 |
+
" If the text contains Hate: Set the last digit (11th) to 1; otherwise, set it to 0.\n\n"
|
| 81 |
+
"Example:\n"
|
| 82 |
+
"For the text 'I love your videos but still something is missing':\n"
|
| 83 |
+
" - Emotion: Cold and Warm (CW)\n"
|
| 84 |
+
" - Types Detected: 2 (Appreciation), 3 (Constructive Criticism), 5 (Advice/Suggestions)\n"
|
| 85 |
+
" - Special Categories: Neutral/General (set the 10th digit to 1), no Hate\n\n"
|
| 86 |
+
"The output would be: CW02305000010\n\n"
|
| 87 |
+
"Output Format:\n"
|
| 88 |
+
"Always return a 13-character code following this structure.",
|
| 89 |
+
label="Instructions",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
lines=10,
|
| 91 |
),
|
| 92 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|