Spaces:
Paused
Paused
updated app.py
Browse files
app.py
CHANGED
@@ -72,10 +72,15 @@ def test_rag(query):
|
|
72 |
|
73 |
# OAuth Login Functionality
|
74 |
def oauth_login():
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
79 |
return login_url
|
80 |
|
81 |
# Define the Gradio interface
|
@@ -95,7 +100,6 @@ def clear_input():
|
|
95 |
def on_login(success):
|
96 |
return gr.update(visible=success), gr.update(visible=success)
|
97 |
|
98 |
-
# Gradio interface
|
99 |
with gr.Blocks() as interface:
|
100 |
gr.Markdown("## RAG Chatbot")
|
101 |
gr.Markdown("Ask a question and get answers based on retrieved documents.")
|
@@ -110,7 +114,11 @@ with gr.Blocks() as interface:
|
|
110 |
login_btn.click(lambda: oauth_login(), outputs=None) # Redirect user for OAuth login
|
111 |
|
112 |
# Show components after login
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
submit_btn.click(chat, inputs=[input_box, chat_history], outputs=[chat_history, input_box])
|
115 |
|
116 |
interface.launch()
|
|
|
72 |
|
73 |
# OAuth Login Functionality
|
74 |
def oauth_login():
|
75 |
+
params = {
|
76 |
+
'client_id': CLIENT_ID,
|
77 |
+
'response_type': 'code',
|
78 |
+
'redirect_uri': REDIRECT_URI,
|
79 |
+
'response_mode': 'query',
|
80 |
+
'scope': SCOPE,
|
81 |
+
'state': 'random_state_string' # Optional: Use for security
|
82 |
+
}
|
83 |
+
login_url = f"{AUTH_URL}?{urlencode(params)}"
|
84 |
return login_url
|
85 |
|
86 |
# Define the Gradio interface
|
|
|
100 |
def on_login(success):
|
101 |
return gr.update(visible=success), gr.update(visible=success)
|
102 |
|
|
|
103 |
with gr.Blocks() as interface:
|
104 |
gr.Markdown("## RAG Chatbot")
|
105 |
gr.Markdown("Ask a question and get answers based on retrieved documents.")
|
|
|
114 |
login_btn.click(lambda: oauth_login(), outputs=None) # Redirect user for OAuth login
|
115 |
|
116 |
# Show components after login
|
117 |
+
def show_components():
|
118 |
+
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
119 |
+
|
120 |
+
# After a successful login, show the input box and buttons
|
121 |
+
submit_btn.click(show_components, outputs=[input_box, submit_btn, chat_history])
|
122 |
submit_btn.click(chat, inputs=[input_box, chat_history], outputs=[chat_history, input_box])
|
123 |
|
124 |
interface.launch()
|