mikaelmp commited on
Commit
7368a7d
Β·
verified Β·
1 Parent(s): 161ceda

Moved British to parsing, included prohibited topics to validation

Browse files
researchsimulation/InteractiveInterviewChatbot.py CHANGED
@@ -31,7 +31,14 @@ def parse_question_with_llm(question, respondent_names, processor_llm):
31
  - Keep all other wording, punctuation, and sentence structure exactly as in the original. Do NOT rephrase or rewrite under any circumstance.
32
  3. If no respondent is explicitly addressed, return "General" as the respondent name.
33
  4. If the question is posed to all respondents, return "All" as the respondent name.
34
- 5. Ensure that you follow the **Formatting Rules** exactly. THIS IS EXTREMELY IMPORTANT.
 
 
 
 
 
 
 
35
 
36
  ### Examples:
37
  - "Sourav, do you agree with this topic?" β†’ "Do you agree with this topic?"
@@ -40,6 +47,10 @@ def parse_question_with_llm(question, respondent_names, processor_llm):
40
  - "What do you think, Divya, about this topic?" β†’ "What do you think about this topic?"
41
  - "Do you, Rahul, agree with this statement?" β†’ "Do you agree with this statement?"
42
  - "Are you, Sourav, going to do this?" β†’ "Are you going to do this?"
 
 
 
 
43
 
44
  ### **Formatting Rules**:
45
  For each question identified, respond using **only** the following format:
@@ -103,17 +114,45 @@ def validate_question_topics(parsed_questions, processor_llm):
103
  - Social & Societal Issues: Gender equality, societal expectations, economic issues, tradition vs freedom, social development.
104
  - Lifestyle Preferences: Food preferences, fashion, routines, spending habits, religious or cultural practices.
105
  - Personal Growth & Development: Maturity, emotional regulation, responsibility, adaptability, self-improvement, learning mindset.
106
-
107
  ### Validation Instructions:
108
- - Judge based on **intent** and **relevance**.
109
- - Accept the question if it is **clearly relevant to the permitted topics** and something the respondent could **reasonably be expected to answer or reflect on**.
110
- - Be cautious with speculative or technical questions (e.g. cryptocurrency, political policies) β€” only allow if they're framed in a **personal or lifestyle** context that the respondent could discuss.
111
- - If a question is **clearly unrelated**, overly technical, or beyond the respondent's likely knowledge or experience, respond with exactly: "INVALID".
112
- - If valid, return the **same question**, rewritten in **British English** if necessary.
113
- - Do not add any new content or change the meaning β€” only apply British spelling, grammar, and phrasing.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  ### Output:
115
- <Validated question in British English, or "INVALID">
116
  """
 
 
 
 
 
 
 
 
 
 
117
 
118
  # ### Stricter Validation Instructions:
119
  # - If the question is not strictly relevant to the **Permitted Topics Scope**, it is invalid. Replace the queston with exactly: "INVALID"
 
31
  - Keep all other wording, punctuation, and sentence structure exactly as in the original. Do NOT rephrase or rewrite under any circumstance.
32
  3. If no respondent is explicitly addressed, return "General" as the respondent name.
33
  4. If the question is posed to all respondents, return "All" as the respondent name.
34
+ 5. Rewrite the question in **British English** if necessary.
35
+ - Do not rephrase beyond British spelling or grammar.
36
+ - Do not add, remove, or change the meaning of the question.
37
+ - Where there are regional variations (e.g. 'licence' vs 'license', 'programme' vs 'program', 'aeroplane' vs 'airplane'), always default to the standard British form.
38
+ - Examples:
39
+ - **Correct (British):** organised, prioritise, minimise, realise, behaviour, centre, defence, travelling, practise (verb), licence (noun), programme, aeroplane.
40
+ - **Incorrect (American):** organized, prioritize, minimize, realize, behavior, center, defense, traveling, practice (verb and noun), license (noun), program, airplane.
41
+ 6. Ensure that you follow the **Formatting Rules** exactly. THIS IS EXTREMELY IMPORTANT.
42
 
43
  ### Examples:
44
  - "Sourav, do you agree with this topic?" β†’ "Do you agree with this topic?"
 
47
  - "What do you think, Divya, about this topic?" β†’ "What do you think about this topic?"
48
  - "Do you, Rahul, agree with this statement?" β†’ "Do you agree with this statement?"
49
  - "Are you, Sourav, going to do this?" β†’ "Are you going to do this?"
50
+ - "What is your favorite color, Meena?" β†’ "What is your favourite colour?"
51
+ - "Divya, what did you learn from this program?" β†’ "What did you learn from this programme?"
52
+ - "How do you stay organized, Rahul?" β†’ "How do you stay organised?"
53
+ - "Meena, how do you balance work and traveling?" β†’ "How do you balance work and travelling?"
54
 
55
  ### **Formatting Rules**:
56
  For each question identified, respond using **only** the following format:
 
114
  - Social & Societal Issues: Gender equality, societal expectations, economic issues, tradition vs freedom, social development.
115
  - Lifestyle Preferences: Food preferences, fashion, routines, spending habits, religious or cultural practices.
116
  - Personal Growth & Development: Maturity, emotional regulation, responsibility, adaptability, self-improvement, learning mindset.
117
+
118
  ### Validation Instructions:
119
+ You must determine if the question is appropriate for a lifestyle, values, and personal development interview.
120
+
121
+ 1. **Topical Relevance**
122
+ - Accept the question only if it is **clearly relevant** to the Permitted Topics Scope and can be answered from a **personal, lifestyle, or values-based perspective**.
123
+
124
+ 2. **Content Restrictions**
125
+ Return exactly "INVALID" if the question contains any of the following:
126
+ - Hate speech, discrimination, harassment
127
+ - Sexually explicit, violent, or graphic content
128
+ - Religious extremism or proselytising
129
+ - Politically sensitive content:
130
+ - Opinions or knowledge about politicians or political parties
131
+ - Policy debates, election-related topics, or partisan comparisons
132
+ - References to extremist ideologies or hate groups
133
+ - Overly technical, academic, or scientific content not grounded in personal lifestyle (e.g. biology, physics, finance, geopolitics)
134
+ - News-related or controversial current events
135
+
136
+ 3. **Everyday Relevance**
137
+ - Even if the topic superficially fits the scope, it must be **personally relatable, non-controversial**, and answerable by someone with the respondent's **general life experience**, not specialised knowledge.
138
+
139
+ 4. **Output Instructions**
140
+ - If invalid, return exactly: "INVALID"
141
+ - If valid, return the **same question**
142
+
143
  ### Output:
144
+ <Validated question OR "INVALID">
145
  """
146
+
147
+ # ### Validation Instructions:
148
+ # - Judge based on **intent** and **relevance**.
149
+ # - Accept the question if it is **clearly relevant to the permitted topics** and something the respondent could **reasonably be expected to answer or reflect on**.
150
+ # - Be cautious with speculative or technical questions (e.g. cryptocurrency, political policies) β€” only allow if they're framed in a **personal or lifestyle** context that the respondent could discuss.
151
+ # - If a question is **clearly unrelated**, overly technical, or beyond the respondent's likely knowledge or experience, respond with exactly: "INVALID".
152
+ # - If valid, return the **same question**, rewritten in **British English** if necessary.
153
+ # - Do not add any new content or change the meaning β€” only apply British spelling, grammar, and phrasing.
154
+ # ### Output:
155
+ # <Validated question, or "INVALID">
156
 
157
  # ### Stricter Validation Instructions:
158
  # - If the question is not strictly relevant to the **Permitted Topics Scope**, it is invalid. Replace the queston with exactly: "INVALID"