Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,25 +18,32 @@ def generate_text(prompt):
|
|
| 18 |
)
|
| 19 |
return response.choices[0].text.strip()
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
fn=generate_text,
|
| 27 |
inputs=input_text,
|
| 28 |
outputs=output_text,
|
| 29 |
title="AI Chatbot for PlanetTogether Knowledge Base",
|
| 30 |
description="Ask a question about the PlanetTogether APS:",
|
| 31 |
-
examples=[["How do you
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
-
demo.password_box = password_box
|
| 37 |
-
|
| 38 |
-
# Set the initial state of the interface
|
| 39 |
-
demo.interface.visible = False
|
| 40 |
|
| 41 |
# Launch demo with password protection
|
| 42 |
demo.launch(config={"callbacks": [check_password]})
|
|
|
|
| 18 |
)
|
| 19 |
return response.choices[0].text.strip()
|
| 20 |
|
| 21 |
+
# Define password-protected Gradio interface
|
| 22 |
+
def check_password(password):
|
| 23 |
+
if password == "password":
|
| 24 |
+
demo.interface.visible = True
|
| 25 |
+
demo.password_box.visible = False
|
| 26 |
+
else:
|
| 27 |
+
demo.interface.visible = False
|
| 28 |
+
demo.password_box.visible = True
|
| 29 |
+
|
| 30 |
+
input_text = gr.Textbox(label="Enter prompt", placeholder="Type your question here...", lines=7)
|
| 31 |
+
output_text = gr.Textbox(label="AI Response", placeholder="AI will respond here...", lines=7)
|
| 32 |
+
password_box = gr.Textbox(label="Enter password to access the app", type="password")
|
| 33 |
+
|
| 34 |
+
demo = gr.Interface(
|
| 35 |
fn=generate_text,
|
| 36 |
inputs=input_text,
|
| 37 |
outputs=output_text,
|
| 38 |
title="AI Chatbot for PlanetTogether Knowledge Base",
|
| 39 |
description="Ask a question about the PlanetTogether APS:",
|
| 40 |
+
examples=[["How do you create an Alternate Path?"]],
|
| 41 |
+
theme="default",
|
| 42 |
+
allow_flagging=False,
|
| 43 |
+
layout="vertical",
|
| 44 |
+
inputs_visibility=False
|
| 45 |
)
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# Launch demo with password protection
|
| 49 |
demo.launch(config={"callbacks": [check_password]})
|