Abu1998 commited on
Commit
4a32a9f
·
verified ·
1 Parent(s): 5c8227d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -40,7 +40,12 @@ def respond(
40
  ):
41
  token = message.choices[0].delta.content
42
  response += token
43
- yield response
 
 
 
 
 
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
- label="""
55
- 1. Emotion Temperature Code (2 characters):
56
- - If the emotion is purely Cold: Use CC
57
- - If the emotion is purely Warm: Use WW
58
- - If the emotion is purely Hot: Use HH
59
- - If the emotion is a mix, use one of the following:
60
- - Cold and Warm: Use CW
61
- - Warm and Hot: Use WH
62
- - Cold and Hot: Use CH
63
-
64
- 2. Text Type Codes (next 9 digits):
65
- Assign a digit for each of the following categories based on the presence in the text. Use 0 for categories not applicable:
66
- 1: Toxic
67
- 2: Appreciation
68
- 3: Constructive Criticism
69
- 4: Genuine Questions
70
- 5: Advice/Suggestions
71
- 6: Requests
72
- 7: Spam
73
- 8: Off-Topic
74
- 9: Engagement Boosters
75
-
76
- 3. Special Categories (last 2 digits):
77
- If the text is Neutral/General: Set the 10th digit to 1; otherwise, set it to 0.
78
- If the text contains Hate: Set the last digit (11th) to 1; otherwise, set it to 0.
79
-
80
- Example:
81
- For the text "I love your videos but still something is missing":
82
- - Emotion: Cold and Warm (CW)
83
- - Types Detected: 2 (Appreciation), 3 (Constructive Criticism), 5 (Advice/Suggestions)
84
- - Special Categories: Neutral/General (set the 10th digit to 1), no Hate
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"),