Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -115,21 +115,6 @@ with gr.Blocks() as demo:
|
|
| 115 |
else:
|
| 116 |
return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key"), gr.update(visible=False)
|
| 117 |
|
| 118 |
-
def parse_participants(input_string: str) -> list:
|
| 119 |
-
# Replace <br> tags with newline characters
|
| 120 |
-
input_string = input_string.replace("<br>", "\n")
|
| 121 |
-
|
| 122 |
-
# Split the input string using a regular expression for “Participant X”
|
| 123 |
-
participants = re.split(r'Participant \d+:\n', input_string)[1:] # Ignore the first split item since it’s empty
|
| 124 |
-
|
| 125 |
-
# Parse each participant’s details and add them to a list
|
| 126 |
-
participant_details = []
|
| 127 |
-
for participant in participants:
|
| 128 |
-
details = '\n'.join(participant.strip().split("\n"))
|
| 129 |
-
participant_details.append(details)
|
| 130 |
-
|
| 131 |
-
return participant_details
|
| 132 |
-
|
| 133 |
def summarize(title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10):
|
| 134 |
prompt = f"""
|
| 135 |
You are asked to make a report summarizing the inputs from 10 participants from a focus groups on this topic:
|
|
@@ -348,7 +333,22 @@ Now please provide your results.
|
|
| 348 |
results.append(result)
|
| 349 |
|
| 350 |
return results[0], results[1], results[2], results[3], results[4], results[5], results[6], results[7], results[8], results[9]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
|
|
|
|
|
|
|
| 352 |
def generateprofiles(title, question1, question2, question3, focusgroupdescription):
|
| 353 |
prompt = f"""
|
| 354 |
Please generate 10 profiles for a focus group that would have the following features:
|
|
@@ -413,10 +413,11 @@ Here are 2 examples of profiles for inspiration (for a focus group on sparkling
|
|
| 413 |
Now please provide your results.
|
| 414 |
"""
|
| 415 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
|
|
|
| 420 |
return list[0], list[1], list[2], list[3], list[4], list[5], list[6], list[7], list[8], list[9]
|
| 421 |
|
| 422 |
def answer(formmatedprompt, model):
|
|
|
|
| 115 |
else:
|
| 116 |
return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key"), gr.update(visible=False)
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
def summarize(title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10):
|
| 119 |
prompt = f"""
|
| 120 |
You are asked to make a report summarizing the inputs from 10 participants from a focus groups on this topic:
|
|
|
|
| 333 |
results.append(result)
|
| 334 |
|
| 335 |
return results[0], results[1], results[2], results[3], results[4], results[5], results[6], results[7], results[8], results[9]
|
| 336 |
+
|
| 337 |
+
def parse_participants(input_string: str) -> list:
|
| 338 |
+
# Replace <br> tags with newline characters
|
| 339 |
+
input_string = input_string.replace("<br>", "\n")
|
| 340 |
+
|
| 341 |
+
# Split the input string using a regular expression for “Participant X”
|
| 342 |
+
participants = re.split(r'Participant \d+:\n', input_string)[1:] # Ignore the first split item since it’s empty
|
| 343 |
+
|
| 344 |
+
# Parse each participant’s details and add them to a list
|
| 345 |
+
participant_details = []
|
| 346 |
+
for participant in participants:
|
| 347 |
+
details = '\n'.join(participant.strip().split("\n"))
|
| 348 |
+
participant_details.append(details)
|
| 349 |
|
| 350 |
+
return participant_details
|
| 351 |
+
|
| 352 |
def generateprofiles(title, question1, question2, question3, focusgroupdescription):
|
| 353 |
prompt = f"""
|
| 354 |
Please generate 10 profiles for a focus group that would have the following features:
|
|
|
|
| 413 |
Now please provide your results.
|
| 414 |
"""
|
| 415 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 416 |
+
list = []
|
| 417 |
+
while len(list) <10:
|
| 418 |
+
result = answer(formattedprompt, "gpt-3.5-turbo-16k")
|
| 419 |
+
#break it down
|
| 420 |
+
list = parse_participants(result)
|
| 421 |
return list[0], list[1], list[2], list[3], list[4], list[5], list[6], list[7], list[8], list[9]
|
| 422 |
|
| 423 |
def answer(formmatedprompt, model):
|