Spaces:
Build error
Build error
Update researchsimulation/InteractiveInterviewChatbot.py
Browse files
researchsimulation/InteractiveInterviewChatbot.py
CHANGED
|
@@ -302,10 +302,10 @@ def tailor_answer_to_profile(agent_name, generic_answer, agent_question, user_pr
|
|
| 302 |
tone = user_profile.get_field("Communication", "Tone")
|
| 303 |
length = user_profile.get_field("Communication", "Length")
|
| 304 |
topics = user_profile.get_field("Communication", "Topics")
|
| 305 |
-
|
| 306 |
-
task_description = f"""
|
| 307 |
-
You are {agent_name}. Rewrite the following answer to match your personal communication style and tone preferences.
|
| 308 |
|
|
|
|
|
|
|
|
|
|
| 309 |
---
|
| 310 |
### Original Generic Answer:
|
| 311 |
{generic_answer}
|
|
@@ -313,17 +313,32 @@ def tailor_answer_to_profile(agent_name, generic_answer, agent_question, user_pr
|
|
| 313 |
---
|
| 314 |
### Question:
|
| 315 |
"{agent_question}"
|
| 316 |
-
|
| 317 |
---
|
| 318 |
### *Communication Profile Reference:*
|
| 319 |
- **Style:** {style}
|
| 320 |
- **Tone:** {tone}
|
| 321 |
- **Length:** {length}
|
| 322 |
- **Topics:** {topics}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
---
|
| 325 |
### Hard Rules – You Must Follow These Without Exception:
|
| 326 |
-
-
|
|
|
|
| 327 |
- Do **not** introduce new information or elaborate beyond what’s stated.
|
| 328 |
- Use **first person** ("I", "my", etc.) — never speak in third person.
|
| 329 |
- Always use **British English** spelling, punctuation, and grammar.
|
|
@@ -332,20 +347,20 @@ def tailor_answer_to_profile(agent_name, generic_answer, agent_question, user_pr
|
|
| 332 |
- Do **not** include emojis, hashtags, placeholders, or third-person descriptions.
|
| 333 |
- Maintain **narrative consistency** across responses to reflect a coherent personality.
|
| 334 |
- Tailor phrasing, sentence structure, and vocabulary to fit your **persona** and **communication traits**.
|
| 335 |
-
|
| 336 |
---
|
| 337 |
### Personality Trait Alignment:
|
| 338 |
Ensure your answer reflects these aspects of your personality profile:
|
| 339 |
- Big Five Traits (e.g., Openness, Extraversion)
|
| 340 |
- Values and Priorities (e.g., Risk Tolerance, Achievement Orientation)
|
| 341 |
- Communication Preferences (e.g., Directness, Emotional Expressiveness)
|
| 342 |
-
|
| 343 |
---
|
| 344 |
Final Output:
|
| 345 |
-
|
| 346 |
-
|
| 347 |
"""
|
| 348 |
-
|
| 349 |
logging.debug(f"[tailor_answer_to_profile] Task description preview: {task_description[:300]}...")
|
| 350 |
logging.info("[tailor_answer_to_profile] Initialising Task and Crew objects")
|
| 351 |
|
|
|
|
| 302 |
tone = user_profile.get_field("Communication", "Tone")
|
| 303 |
length = user_profile.get_field("Communication", "Length")
|
| 304 |
topics = user_profile.get_field("Communication", "Topics")
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
+
task_description = f"""
|
| 307 |
+
You are {agent_name}. Rewrite the following answer to match your personal communication style and tone preferences — **but only if the question is subjective or personal**.
|
| 308 |
+
|
| 309 |
---
|
| 310 |
### Original Generic Answer:
|
| 311 |
{generic_answer}
|
|
|
|
| 313 |
---
|
| 314 |
### Question:
|
| 315 |
"{agent_question}"
|
| 316 |
+
|
| 317 |
---
|
| 318 |
### *Communication Profile Reference:*
|
| 319 |
- **Style:** {style}
|
| 320 |
- **Tone:** {tone}
|
| 321 |
- **Length:** {length}
|
| 322 |
- **Topics:** {topics}
|
| 323 |
+
|
| 324 |
+
---
|
| 325 |
+
### Important Note on Factual Questions:
|
| 326 |
+
If the question is a **factual or demographic one** (e.g., about age, name, location, occupation, birthplace), do **not** rewrite or stylise the answer. Just return the generic answer exactly as it is.
|
| 327 |
|
| 328 |
+
Factual examples include:
|
| 329 |
+
- Where are you from?
|
| 330 |
+
- How old are you?
|
| 331 |
+
- What is your name?
|
| 332 |
+
- Where do you live?
|
| 333 |
+
- What do you do?
|
| 334 |
+
- Where were you born?
|
| 335 |
+
|
| 336 |
+
Only rewrite if the question invites a **personal perspective, opinion, habit, or belief**.
|
| 337 |
+
|
| 338 |
---
|
| 339 |
### Hard Rules – You Must Follow These Without Exception:
|
| 340 |
+
- If the question is factual → **return the generic answer unchanged**.
|
| 341 |
+
- If the question is personal → Keep the **meaning** and **personal point of view** of the original generic answer.
|
| 342 |
- Do **not** introduce new information or elaborate beyond what’s stated.
|
| 343 |
- Use **first person** ("I", "my", etc.) — never speak in third person.
|
| 344 |
- Always use **British English** spelling, punctuation, and grammar.
|
|
|
|
| 347 |
- Do **not** include emojis, hashtags, placeholders, or third-person descriptions.
|
| 348 |
- Maintain **narrative consistency** across responses to reflect a coherent personality.
|
| 349 |
- Tailor phrasing, sentence structure, and vocabulary to fit your **persona** and **communication traits**.
|
| 350 |
+
|
| 351 |
---
|
| 352 |
### Personality Trait Alignment:
|
| 353 |
Ensure your answer reflects these aspects of your personality profile:
|
| 354 |
- Big Five Traits (e.g., Openness, Extraversion)
|
| 355 |
- Values and Priorities (e.g., Risk Tolerance, Achievement Orientation)
|
| 356 |
- Communication Preferences (e.g., Directness, Emotional Expressiveness)
|
| 357 |
+
|
| 358 |
---
|
| 359 |
Final Output:
|
| 360 |
+
- If the question is factual: return this answer exactly → **"{generic_answer}"**
|
| 361 |
+
- If not: return a single paragraph answer that matches the respondent’s tone and style, while strictly preserving the original meaning and personal voice from this answer.
|
| 362 |
"""
|
| 363 |
+
|
| 364 |
logging.debug(f"[tailor_answer_to_profile] Task description preview: {task_description[:300]}...")
|
| 365 |
logging.info("[tailor_answer_to_profile] Initialising Task and Crew objects")
|
| 366 |
|