Spaces:
Runtime error
Runtime error
Update Chatbot_new.py
Browse files- Chatbot_new.py +19 -39
Chatbot_new.py
CHANGED
|
@@ -395,8 +395,7 @@ def generate_internal_external_options(chat_history, vignette, user_state):
|
|
| 395 |
|
| 396 |
return response.choices[0].message.content.strip()
|
| 397 |
|
| 398 |
-
# Function to generate stable-unstable and global-specific
|
| 399 |
-
def generate_stable_unstable_options(chat_history, vignette, previous_choice, user_state):
|
| 400 |
# Determine the attribution type based on the user's previous choice
|
| 401 |
formatted_history = []
|
| 402 |
for user_msg, assistant_msg in chat_history:
|
|
@@ -413,45 +412,27 @@ def generate_stable_unstable_options(chat_history, vignette, previous_choice, us
|
|
| 413 |
attribution_type = 'Internal' # Default to Internal if unexpected input
|
| 414 |
|
| 415 |
prompt = f"""
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
1. [Stable and Global] - Provide a concise, {attribution_type.lower()} cause that is consistent over time and impacts multiple areas.
|
| 434 |
-
2. [Stable and Specific] - Provide a concise, {attribution_type.lower()} cause that is consistent but affects only this situation.
|
| 435 |
-
3. [Unstable and Global] - Provide a concise, {attribution_type.lower()} cause that is temporary but has broader implications.
|
| 436 |
-
4. [Unstable and Specific] - Provide a concise, {attribution_type.lower()} cause that is temporary and limited to this particular situation.
|
| 437 |
-
|
| 438 |
-
Each option should be concise and focus on the main idea without including excessive detail. Ensure the options are unique and clear, without overwhelming the user.
|
| 439 |
-
|
| 440 |
-
Only present the four options without explicitly stating the associated dimensions (i.e., Stable, Unstable, Global, Specific). The options should be in simple sentences that are easy to understand.
|
| 441 |
-
|
| 442 |
-
Ensure the options are directly relevant to the scenario, specific, and reflect the {attribution_type} attribution selected by the user.
|
| 443 |
-
|
| 444 |
-
Use simple, but neutral and professional language suitable for a psychological assessment.
|
| 445 |
-
|
| 446 |
-
Do not include any additional text or explanation.
|
| 447 |
-
|
| 448 |
-
Do not include any personal identifying information.
|
| 449 |
-
"""
|
| 450 |
|
| 451 |
messages = [
|
| 452 |
-
{"role": "system", "content": "You are a
|
| 453 |
{"role": "user", "content": prompt},
|
| 454 |
-
] + formatted_history
|
| 455 |
|
| 456 |
response = openai.chat.completions.create(
|
| 457 |
model="gpt-4o-mini",
|
|
@@ -462,7 +443,6 @@ def generate_stable_unstable_options(chat_history, vignette, previous_choice, us
|
|
| 462 |
|
| 463 |
return response.choices[0].message.content.strip()
|
| 464 |
|
| 465 |
-
|
| 466 |
# First reveal
|
| 467 |
def generate_first_reveal(vignette, user_state):
|
| 468 |
prompt = f"""
|
|
|
|
| 395 |
|
| 396 |
return response.choices[0].message.content.strip()
|
| 397 |
|
| 398 |
+
# Function to generate stable-unstable and global-specific optionsdef generate_stable_unstable_options(chat_history, vignette, previous_choice, user_state):
|
|
|
|
| 399 |
# Determine the attribution type based on the user's previous choice
|
| 400 |
formatted_history = []
|
| 401 |
for user_msg, assistant_msg in chat_history:
|
|
|
|
| 412 |
attribution_type = 'Internal' # Default to Internal if unexpected input
|
| 413 |
|
| 414 |
prompt = f"""
|
| 415 |
+
Generate exactly four short statements explaining what might have led to this situation, each on its own line, with no additional comments or explanations. They should reflect a {attribution_type.lower()} cause and cover:
|
| 416 |
+
1) Stable & Global
|
| 417 |
+
2) Stable & Specific
|
| 418 |
+
3) Unstable & Global
|
| 419 |
+
4) Unstable & Specific
|
| 420 |
+
|
| 421 |
+
Instructions:
|
| 422 |
+
- Do not label them as stable/global/etc. in the text itself.
|
| 423 |
+
- Start each line with "1.", "2.", "3.", or "4." only.
|
| 424 |
+
- Keep the language simple, pragmatic, and relevant to the scenario:
|
| 425 |
+
"{vignette}"
|
| 426 |
+
- Each statement should be concise, neutral, and easy to understand, without extra commentary.
|
| 427 |
+
- Do not include disclaimers, personal info, or text beyond the four statements.
|
| 428 |
+
|
| 429 |
+
Previous user attribution type: {attribution_type}
|
| 430 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
|
| 432 |
messages = [
|
| 433 |
+
{"role": "system", "content": "You are a strict output assistant. Produce only the specified lines."},
|
| 434 |
{"role": "user", "content": prompt},
|
| 435 |
+
] + formatted_history
|
| 436 |
|
| 437 |
response = openai.chat.completions.create(
|
| 438 |
model="gpt-4o-mini",
|
|
|
|
| 443 |
|
| 444 |
return response.choices[0].message.content.strip()
|
| 445 |
|
|
|
|
| 446 |
# First reveal
|
| 447 |
def generate_first_reveal(vignette, user_state):
|
| 448 |
prompt = f"""
|