Spaces:
Runtime error
Runtime error
Claude commited on
fix: Remove OAuth from demo.load to prevent auth loops
Browse filesThe visibility toggling with OAuth profile in demo.load was causing
"Max challenge attempts exceeded" errors. Simplified to always show
the chat interface with login button visible.
app.py
CHANGED
|
@@ -866,79 +866,59 @@ def create_demo() -> gr.Blocks:
|
|
| 866 |
"""
|
| 867 |
)
|
| 868 |
|
| 869 |
-
# Login
|
| 870 |
-
with gr.
|
| 871 |
-
gr.
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
height=400,
|
| 888 |
-
type="messages",
|
| 889 |
)
|
|
|
|
| 890 |
|
| 891 |
-
|
|
|
|
|
|
|
| 892 |
with gr.Row():
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
placeholder="Paste a YouTube URL or ask a question...",
|
| 896 |
-
scale=5,
|
| 897 |
-
lines=1,
|
| 898 |
-
)
|
| 899 |
-
send_btn = gr.Button("Send", variant="primary", scale=1)
|
| 900 |
-
|
| 901 |
-
# Voice input/output row
|
| 902 |
-
with gr.Accordion("Voice Mode", open=False):
|
| 903 |
-
gr.Markdown("*Speak to ask questions and hear responses*")
|
| 904 |
-
with gr.Row():
|
| 905 |
-
voice_input = gr.Audio(
|
| 906 |
-
sources=["microphone"],
|
| 907 |
-
type="filepath",
|
| 908 |
-
label="Click to record your question",
|
| 909 |
-
scale=3,
|
| 910 |
-
)
|
| 911 |
-
voice_btn = gr.Button("Send Voice", variant="secondary", scale=1)
|
| 912 |
-
|
| 913 |
-
audio_output = gr.Audio(
|
| 914 |
-
label="Response",
|
| 915 |
type="filepath",
|
| 916 |
-
|
|
|
|
| 917 |
)
|
|
|
|
| 918 |
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
|
| 923 |
# Initialize session on load
|
| 924 |
def init_session(
|
| 925 |
current_state: SessionState | None,
|
| 926 |
-
|
| 927 |
-
) -> tuple[list[dict], str, SessionState, gr.Column, gr.Column]:
|
| 928 |
"""Initialize session state and welcome message."""
|
| 929 |
if current_state is None:
|
| 930 |
-
current_state = create_session_state(
|
| 931 |
-
welcome = get_welcome_message(
|
| 932 |
stats = get_knowledge_stats(current_state)
|
| 933 |
-
|
| 934 |
-
is_logged_in = profile is not None
|
| 935 |
-
return (
|
| 936 |
-
welcome,
|
| 937 |
-
stats,
|
| 938 |
-
current_state,
|
| 939 |
-
gr.Column(visible=not is_logged_in), # login_prompt
|
| 940 |
-
gr.Column(visible=is_logged_in), # chat_interface
|
| 941 |
-
)
|
| 942 |
|
| 943 |
def handle_voice_chat(
|
| 944 |
audio_path: str,
|
|
@@ -1013,7 +993,7 @@ def create_demo() -> gr.Blocks:
|
|
| 1013 |
demo.load(
|
| 1014 |
fn=init_session,
|
| 1015 |
inputs=[session_state],
|
| 1016 |
-
outputs=[chatbot, kb_status, session_state
|
| 1017 |
)
|
| 1018 |
|
| 1019 |
return demo
|
|
|
|
| 866 |
"""
|
| 867 |
)
|
| 868 |
|
| 869 |
+
# Login button row
|
| 870 |
+
with gr.Row():
|
| 871 |
+
gr.LoginButton()
|
| 872 |
+
|
| 873 |
+
# Chat interface
|
| 874 |
+
chatbot = gr.Chatbot(
|
| 875 |
+
label="Video Analyzer",
|
| 876 |
+
height=400,
|
| 877 |
+
type="messages",
|
| 878 |
+
)
|
| 879 |
+
|
| 880 |
+
# Text input row
|
| 881 |
+
with gr.Row():
|
| 882 |
+
msg_input = gr.Textbox(
|
| 883 |
+
label="Message",
|
| 884 |
+
placeholder="Paste a YouTube URL or ask a question...",
|
| 885 |
+
scale=5,
|
| 886 |
+
lines=1,
|
|
|
|
|
|
|
| 887 |
)
|
| 888 |
+
send_btn = gr.Button("Send", variant="primary", scale=1)
|
| 889 |
|
| 890 |
+
# Voice input/output row
|
| 891 |
+
with gr.Accordion("Voice Mode", open=False):
|
| 892 |
+
gr.Markdown("*Speak to ask questions and hear responses*")
|
| 893 |
with gr.Row():
|
| 894 |
+
voice_input = gr.Audio(
|
| 895 |
+
sources=["microphone"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 896 |
type="filepath",
|
| 897 |
+
label="Click to record your question",
|
| 898 |
+
scale=3,
|
| 899 |
)
|
| 900 |
+
voice_btn = gr.Button("Send Voice", variant="secondary", scale=1)
|
| 901 |
|
| 902 |
+
audio_output = gr.Audio(
|
| 903 |
+
label="Response",
|
| 904 |
+
type="filepath",
|
| 905 |
+
autoplay=True,
|
| 906 |
+
)
|
| 907 |
+
|
| 908 |
+
with gr.Row():
|
| 909 |
+
kb_status = gr.Markdown()
|
| 910 |
+
clear_btn = gr.Button("Clear Chat", size="sm")
|
| 911 |
|
| 912 |
# Initialize session on load
|
| 913 |
def init_session(
|
| 914 |
current_state: SessionState | None,
|
| 915 |
+
) -> tuple[list[dict], str, SessionState]:
|
|
|
|
| 916 |
"""Initialize session state and welcome message."""
|
| 917 |
if current_state is None:
|
| 918 |
+
current_state = create_session_state(None)
|
| 919 |
+
welcome = get_welcome_message(None)
|
| 920 |
stats = get_knowledge_stats(current_state)
|
| 921 |
+
return welcome, stats, current_state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
|
| 923 |
def handle_voice_chat(
|
| 924 |
audio_path: str,
|
|
|
|
| 993 |
demo.load(
|
| 994 |
fn=init_session,
|
| 995 |
inputs=[session_state],
|
| 996 |
+
outputs=[chatbot, kb_status, session_state],
|
| 997 |
)
|
| 998 |
|
| 999 |
return demo
|