Tycohs commited on
Commit
fa332bc
·
1 Parent(s): b2f23d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -17
app.py CHANGED
@@ -3,6 +3,7 @@ import openai
3
  import random
4
  import time
5
  import os
 
6
 
7
  # Set up OpenAI API key
8
  openai.api_key = os.getenv('APICode2')
@@ -60,23 +61,20 @@ with gr.Blocks() as demo:
60
  clear = gr.Button("Clear")
61
  state = gr.State([])
62
 
63
- def parse_participants(input_string):
64
- # Split the input string into lines
65
- lines = input_string.split('<br>')
66
-
67
- # Create an empty list to store participant details
68
- participants = []
69
-
70
- # Iterate through the lines to find participant details
71
- for i, line in enumerate(lines):
72
- if line.startswith('Participant'):
73
- # If the line starts with 'Participant', extract the details of that participant
74
- details = lines[i+1].strip()
75
- if details:
76
- # If the details are not empty, add them to the participants list
77
- participants.append(details)
78
-
79
- return participants
80
 
81
  def generateprofiles(title, question1, question2, question3, focusgroupdescription):
82
  prompt = f"""
 
3
  import random
4
  import time
5
  import os
6
+ import re
7
 
8
  # Set up OpenAI API key
9
  openai.api_key = os.getenv('APICode2')
 
61
  clear = gr.Button("Clear")
62
  state = gr.State([])
63
 
64
+ def parse_participants(input_string: str) -> list:
65
+ # Replace <br> tags with newline characters
66
+ input_string = input_string.replace("<br>", "\n")
67
+
68
+ # Split the input string using a regular expression for "Participant X"
69
+ participants = re.split(r'Participant \d+:\n', input_string)[1:] # Ignore the first split item since it's empty
70
+
71
+ # Parse each participant's details and add them to a list
72
+ participant_details = []
73
+ for participant in participants:
74
+ details = participant.strip().split("\n")
75
+ participant_details.append(details)
76
+
77
+ return participant_details
 
 
 
78
 
79
  def generateprofiles(title, question1, question2, question3, focusgroupdescription):
80
  prompt = f"""