Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
#
|
| 68 |
-
participants = []
|
| 69 |
-
|
| 70 |
-
#
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 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"""
|