mojakob commited on
Commit
83a07ec
·
verified ·
1 Parent(s): 1e59d95

Update Chatbot_new.py

Browse files
Files changed (1) hide show
  1. 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 options
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
- Based on the following scenario:
417
-
418
- "{vignette}"
419
-
420
- The user's previous attribution was of type "{attribution_type}".
421
- Now generate four distinct short statements explaining what might have led to this situation, covering:
422
- 1) Stable & Global
423
- 2) Stable & Specific
424
- 3) Unstable & Global
425
- 4) Unstable & Specific
426
-
427
- Ensure the response includes **exactly four options**, each on a new line.
428
-
429
- Do not add any further text or comments.
430
-
431
- Present the options in exactly the following format:
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 helpful assistant."},
453
  {"role": "user", "content": prompt},
454
- ] + formatted_history # Append the formatted chat 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"""