Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,14 +6,18 @@ import os
|
|
| 6 |
import re
|
| 7 |
|
| 8 |
# Set up OpenAI API key
|
| 9 |
-
openai.api_key = os.getenv('APICode2')
|
| 10 |
system_message = "You are an assistant simulating the behavior of the participants in a focus group and answer a set of questions. Your first task will be to generate the profiles of the focus group then to simulate their answers to the question for each member."
|
| 11 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
with gr.Tab("Enquiry Description"):
|
| 13 |
with gr.Row():
|
| 14 |
gr.Markdown("Describe your project or study")
|
| 15 |
with gr.Row():
|
| 16 |
-
title = gr.Textbox(label='Topic
|
| 17 |
with gr.Row():
|
| 18 |
gr.Markdown("List all your questions")
|
| 19 |
with gr.Row():
|
|
@@ -22,7 +26,7 @@ with gr.Blocks() as demo:
|
|
| 22 |
question2 = gr.Textbox(label="Question 2", lines=2)
|
| 23 |
with gr.Row():
|
| 24 |
question3 = gr.Textbox(label="Question 3", lines=2)
|
| 25 |
-
with gr.Tab("Focus Group
|
| 26 |
with gr.Row():
|
| 27 |
gr.Markdown("Describe types of profiles you want in your focus group")
|
| 28 |
with gr.Row():
|
|
@@ -154,8 +158,8 @@ His answers were:
|
|
| 154 |
Follow these rules:
|
| 155 |
- Summarize the answers per question, start with 'Question 1:' and repeat the question then provide the summary below
|
| 156 |
- Provide your summary per question, breaking down the nuance per demographic or profession or any social / profiling category you see fit
|
| 157 |
-
- Keep
|
| 158 |
-
-
|
| 159 |
|
| 160 |
Now please provide your summary.
|
| 161 |
"""
|
|
@@ -336,7 +340,7 @@ Now please provide your results.
|
|
| 336 |
|
| 337 |
def answer(formmatedprompt):
|
| 338 |
response = openai.ChatCompletion.create(
|
| 339 |
-
model="gpt-4"
|
| 340 |
messages=formmatedprompt
|
| 341 |
)
|
| 342 |
result = response['choices'][0]['message']['content']
|
|
|
|
| 6 |
import re
|
| 7 |
|
| 8 |
# Set up OpenAI API key
|
|
|
|
| 9 |
system_message = "You are an assistant simulating the behavior of the participants in a focus group and answer a set of questions. Your first task will be to generate the profiles of the focus group then to simulate their answers to the question for each member."
|
| 10 |
with gr.Blocks() as demo:
|
| 11 |
+
with gr.Row():
|
| 12 |
+
gr.Markdown("This application generates a focus group to answer your questions.\nFirst list your topic and questions, generate the focus group profile, get their answers and finally access the summary report")
|
| 13 |
+
with gr.Row():
|
| 14 |
+
apikey = gr.Textbox(label='Paste here your OpenAI - API key', info='No API key is stored and only you will see it.', lines = 1)
|
| 15 |
+
openai.api_key = os.getenv('APICode2') # openai.api_key = apikey
|
| 16 |
with gr.Tab("Enquiry Description"):
|
| 17 |
with gr.Row():
|
| 18 |
gr.Markdown("Describe your project or study")
|
| 19 |
with gr.Row():
|
| 20 |
+
title = gr.Textbox(label='Topic you would like to submit to your focus group', lines = 5)
|
| 21 |
with gr.Row():
|
| 22 |
gr.Markdown("List all your questions")
|
| 23 |
with gr.Row():
|
|
|
|
| 26 |
question2 = gr.Textbox(label="Question 2", lines=2)
|
| 27 |
with gr.Row():
|
| 28 |
question3 = gr.Textbox(label="Question 3", lines=2)
|
| 29 |
+
with gr.Tab("Focus Group Profiles Generation"):
|
| 30 |
with gr.Row():
|
| 31 |
gr.Markdown("Describe types of profiles you want in your focus group")
|
| 32 |
with gr.Row():
|
|
|
|
| 158 |
Follow these rules:
|
| 159 |
- Summarize the answers per question, start with 'Question 1:' and repeat the question then provide the summary below
|
| 160 |
- Provide your summary per question, breaking down the nuance per demographic or profession or any social / profiling category you see fit
|
| 161 |
+
- Keep all the points raised by the participants with details, break them down in a rational and professional way
|
| 162 |
+
- For each question, provide a recommendation for action to address the needs expressed in the answers for each question, start it with "Recommendation:" then add your prespecriptions on bullet points just asfter
|
| 163 |
|
| 164 |
Now please provide your summary.
|
| 165 |
"""
|
|
|
|
| 340 |
|
| 341 |
def answer(formmatedprompt):
|
| 342 |
response = openai.ChatCompletion.create(
|
| 343 |
+
model="gpt-3.5-turbo-16k", #"gpt-4"
|
| 344 |
messages=formmatedprompt
|
| 345 |
)
|
| 346 |
result = response['choices'][0]['message']['content']
|