Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,10 @@ import time
|
|
| 5 |
import os
|
| 6 |
import re
|
| 7 |
import time
|
| 8 |
-
from openai import OpenAI
|
| 9 |
|
| 10 |
# Set up OpenAI API key
|
| 11 |
-
valapikey = ""
|
| 12 |
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."
|
| 13 |
with gr.Blocks() as demo:
|
| 14 |
with gr.Row():
|
|
@@ -114,7 +114,7 @@ with gr.Blocks() as demo:
|
|
| 114 |
|
| 115 |
def checkapiinput(apikey):
|
| 116 |
if apikey != "" and apikey is not None and len(apikey) >=25 and len(apikey) <= 130:
|
| 117 |
-
|
| 118 |
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
|
| 119 |
else:
|
| 120 |
return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key"), gr.update(visible=False)
|
|
@@ -148,7 +148,7 @@ Profile 3:
|
|
| 148 |
Participant answers:
|
| 149 |
{response3}
|
| 150 |
=====================
|
| 151 |
-
Profile
|
| 152 |
{expert4}
|
| 153 |
|
| 154 |
Participant answers:
|
|
@@ -428,9 +428,9 @@ Now please provide your results using the following language: {language}.
|
|
| 428 |
#Now let's try 10 times
|
| 429 |
for attempt in range(10):
|
| 430 |
try:
|
| 431 |
-
#
|
| 432 |
-
|
| 433 |
-
response =
|
| 434 |
model=model,
|
| 435 |
messages=formmatedprompt
|
| 436 |
)
|
|
|
|
| 5 |
import os
|
| 6 |
import re
|
| 7 |
import time
|
| 8 |
+
#from openai import OpenAI
|
| 9 |
|
| 10 |
# Set up OpenAI API key
|
| 11 |
+
#valapikey = ""
|
| 12 |
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."
|
| 13 |
with gr.Blocks() as demo:
|
| 14 |
with gr.Row():
|
|
|
|
| 114 |
|
| 115 |
def checkapiinput(apikey):
|
| 116 |
if apikey != "" and apikey is not None and len(apikey) >=25 and len(apikey) <= 130:
|
| 117 |
+
openai.api_key = apikey
|
| 118 |
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
|
| 119 |
else:
|
| 120 |
return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key"), gr.update(visible=False)
|
|
|
|
| 148 |
Participant answers:
|
| 149 |
{response3}
|
| 150 |
=====================
|
| 151 |
+
Profile
|
| 152 |
{expert4}
|
| 153 |
|
| 154 |
Participant answers:
|
|
|
|
| 428 |
#Now let's try 10 times
|
| 429 |
for attempt in range(10):
|
| 430 |
try:
|
| 431 |
+
#client = OpenAI(api_key= valapikey)
|
| 432 |
+
#response = client.chat.completions.create(
|
| 433 |
+
response = openai.ChatCompletion.create(
|
| 434 |
model=model,
|
| 435 |
messages=formmatedprompt
|
| 436 |
)
|