Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ with gr.Blocks() as demo:
|
|
| 15 |
apikey = gr.Textbox(label='Paste here your OpenAI - API key', info='No API key is stored and only you will see it.', lines = 1)
|
| 16 |
openai.api_key = os.getenv('APICode2') # openai.api_key = apikey
|
| 17 |
with gr.Column(scale = 1):
|
| 18 |
-
useapi = gr.Button("Use this API key)
|
| 19 |
with gr.Row(visible = False) as fullblock:
|
| 20 |
with gr.Tab("Enquiry Description"):
|
| 21 |
with gr.Row():
|
|
@@ -83,10 +83,10 @@ with gr.Blocks() as demo:
|
|
| 83 |
clear = gr.Button("Clear")
|
| 84 |
|
| 85 |
def checkapiinput(apikey):
|
| 86 |
-
if apikey != "" and apikey is not None:
|
| 87 |
-
return gr.update(visible=True), gr.update(visible=False)
|
| 88 |
else:
|
| 89 |
-
return gr.update(visible=False), gr.update(visible=True)
|
| 90 |
|
| 91 |
def parse_participants(input_string: str) -> list:
|
| 92 |
# Replace <br> tags with newline characters
|
|
@@ -361,7 +361,7 @@ Now please provide your results.
|
|
| 361 |
generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
|
| 362 |
generateresults.click(generateanswers, [title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10], [response1, response2, response3, response4, response5, response6, response7, response8, response9, response10])
|
| 363 |
generatesummary.click(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], summary)
|
| 364 |
-
useapi.click(checkapiinput, apikey, [fullblock, apicheck])
|
| 365 |
clear.click(init_history, title, [title, question1, question2, question3, focusgroupdescription, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10, summary])
|
| 366 |
|
| 367 |
demo.launch()
|
|
|
|
| 15 |
apikey = gr.Textbox(label='Paste here your OpenAI - API key', info='No API key is stored and only you will see it.', lines = 1)
|
| 16 |
openai.api_key = os.getenv('APICode2') # openai.api_key = apikey
|
| 17 |
with gr.Column(scale = 1):
|
| 18 |
+
useapi = gr.Button("Use this API key")
|
| 19 |
with gr.Row(visible = False) as fullblock:
|
| 20 |
with gr.Tab("Enquiry Description"):
|
| 21 |
with gr.Row():
|
|
|
|
| 83 |
clear = gr.Button("Clear")
|
| 84 |
|
| 85 |
def checkapiinput(apikey):
|
| 86 |
+
if apikey != "" and apikey is not None and len(apikey) >=25 and len(apikey) <= 130:
|
| 87 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
|
| 88 |
else:
|
| 89 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key")
|
| 90 |
|
| 91 |
def parse_participants(input_string: str) -> list:
|
| 92 |
# Replace <br> tags with newline characters
|
|
|
|
| 361 |
generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
|
| 362 |
generateresults.click(generateanswers, [title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10], [response1, response2, response3, response4, response5, response6, response7, response8, response9, response10])
|
| 363 |
generatesummary.click(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], summary)
|
| 364 |
+
useapi.click(checkapiinput, apikey, [fullblock, apicheck, apikey])
|
| 365 |
clear.click(init_history, title, [title, question1, question2, question3, focusgroupdescription, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10, summary])
|
| 366 |
|
| 367 |
demo.launch()
|