Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,6 +60,24 @@ with gr.Blocks() as demo:
|
|
| 60 |
clear = gr.Button("Clear")
|
| 61 |
state = gr.State([])
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
def generateprofiles(title, question1, question2, question3, focusgroupdescription):
|
| 64 |
prompt = f"""
|
| 65 |
Please generate 10 profiles for a focus group that would have the following features:
|
|
@@ -125,7 +143,10 @@ Now please provide your results.
|
|
| 125 |
"""
|
| 126 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 127 |
result = answer(formattedprompt)
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
def answer(formmatedprompt):
|
| 131 |
response = openai.ChatCompletion.create(
|
|
@@ -146,7 +167,7 @@ Now please provide your results.
|
|
| 146 |
print(f"User input:{chatbot[i][0]}")
|
| 147 |
print(f"Bot output:{chatbot[i][1]}")
|
| 148 |
|
| 149 |
-
generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], expert1)
|
| 150 |
#clear.click(lambda: None, None, chatbot, queue=False).success(init_history, [state], [state])
|
| 151 |
|
| 152 |
demo.launch()
|
|
|
|
| 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"""
|
| 83 |
Please generate 10 profiles for a focus group that would have the following features:
|
|
|
|
| 143 |
"""
|
| 144 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 145 |
result = answer(formattedprompt)
|
| 146 |
+
|
| 147 |
+
#break it down
|
| 148 |
+
list = parse_participants(result)
|
| 149 |
+
return list[0], list[1], list[2], list[3], list[4], list[5], list[6], list[7]], list[8], list[9]
|
| 150 |
|
| 151 |
def answer(formmatedprompt):
|
| 152 |
response = openai.ChatCompletion.create(
|
|
|
|
| 167 |
print(f"User input:{chatbot[i][0]}")
|
| 168 |
print(f"Bot output:{chatbot[i][1]}")
|
| 169 |
|
| 170 |
+
generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
|
| 171 |
#clear.click(lambda: None, None, chatbot, queue=False).success(init_history, [state], [state])
|
| 172 |
|
| 173 |
demo.launch()
|