Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,32 +19,35 @@ def generate_text(prompt):
|
|
| 19 |
return response.choices[0].text.strip()
|
| 20 |
|
| 21 |
# Define password-protected Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
def check_password(password):
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 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 |
-
|
|
|
|
| 45 |
)
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
demo.launch(config={"callbacks": [check_password]})
|
| 50 |
-
|
|
|
|
| 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 |
+
# Define password validation function
|
| 31 |
def check_password(password):
|
| 32 |
+
return password == "password"
|
| 33 |
+
|
| 34 |
+
# Create Gradio interface
|
| 35 |
+
input_text = gr.Textbox(label="Enter prompt", placeholder="Enter prompt", default="How do you create an Alternate Path?", type="password", live=True, lines=2)
|
| 36 |
+
output_text = gr.Textbox(label="AI Response", placeholder="AI Response", type="output", live=True, lines=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
demo = gr.Interface(
|
| 38 |
fn=generate_text,
|
| 39 |
inputs=input_text,
|
| 40 |
outputs=output_text,
|
| 41 |
title="AI Chatbot for PlanetTogether Knowledge Base",
|
| 42 |
+
description="Ask a question about the PlanetTogether APS",
|
| 43 |
examples=[["How do you create an Alternate Path?"]],
|
| 44 |
theme="default",
|
| 45 |
allow_flagging=False,
|
| 46 |
+
allow_screenshot=False,
|
| 47 |
layout="vertical",
|
| 48 |
+
analytics_enabled=False,
|
| 49 |
+
callbacks=[check_password]
|
| 50 |
)
|
| 51 |
|
| 52 |
+
# Launch demo
|
| 53 |
+
demo.launch()
|
|
|
|
|
|