patti-j commited on
Commit
be32b79
·
1 Parent(s): 648a770

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -14
app.py CHANGED
@@ -18,34 +18,41 @@ def generate_text(prompt):
18
  )
19
  return response.choices[0].text.strip()
20
 
21
- def placeholder_fn(input_text):
22
- pass
 
 
 
 
 
 
 
23
 
24
  # Create Gradio interface
25
  password_box = gr.Textbox(label="Enter password", type="password")
26
  input_text = gr.Textbox(label="Enter prompt", type="text")
27
  output_text = gr.Textbox(label="AI response", type="text")
28
  demo = gr.Interface(
29
- fn = placeholder_fn,
30
  inputs=[password_box, input_text],
31
  outputs=output_text,
32
- title="AI Stupid Chatbot for PlanetTogether Knowledge Base",
33
  description="Ask a question about the PlanetTogether APS:",
34
  examples=[["How do you create an Alternate Path?"]],
35
  theme="default"
36
  )
37
 
38
  # Define password-protected Gradio interface
39
- def check_password(password):
40
- if password == "patti-ai":
41
- input_text.visible = True
42
- password_box.visible = False
43
- fn=generate_text
44
- return "Access granted"
45
- else:
46
- input_text.visible = False
47
- password_box.visible = True
48
- return "Access denied"
49
 
50
  # Set function for Gradio interface
51
  demo.fn = check_password
 
18
  )
19
  return response.choices[0].text.strip()
20
 
21
+ # def placeholder_fn(input_text):
22
+ # pass
23
+
24
+ def check_password():
25
+ password = gr.password("Enter password to continue")
26
+ if password != "password":
27
+ print("Incorrect password!")
28
+ return False
29
+ return True
30
 
31
  # Create Gradio interface
32
  password_box = gr.Textbox(label="Enter password", type="password")
33
  input_text = gr.Textbox(label="Enter prompt", type="text")
34
  output_text = gr.Textbox(label="AI response", type="text")
35
  demo = gr.Interface(
36
+ fn = check_password,
37
  inputs=[password_box, input_text],
38
  outputs=output_text,
39
+ title="AI Chatbot for PlanetTogether Knowledge Base",
40
  description="Ask a question about the PlanetTogether APS:",
41
  examples=[["How do you create an Alternate Path?"]],
42
  theme="default"
43
  )
44
 
45
  # Define password-protected Gradio interface
46
+ #def check_password(password):
47
+ # if password == "patti-ai":
48
+ # input_text.visible = True
49
+ # password_box.visible = False
50
+ # fn=generate_text
51
+ # return "Access granted"
52
+ # else:
53
+ # input_text.visible = False
54
+ # password_box.visible = True
55
+ # print "Access denied"
56
 
57
  # Set function for Gradio interface
58
  demo.fn = check_password