mirror of
https://github.com/Cinnamon/kotaemon.git
synced 2026-02-24 03:59:47 +01:00
fix: disable key-based login
This commit is contained in:
@@ -673,7 +673,7 @@ class FileIndexPage(BasePage):
|
||||
fn=self.index_fn_url_with_default_loaders,
|
||||
inputs=[
|
||||
self._app.chat_page.quick_urls,
|
||||
gr.State(value=True),
|
||||
gr.State(value=False),
|
||||
self._app.settings_state,
|
||||
self._app.user_id,
|
||||
],
|
||||
|
||||
@@ -41,6 +41,7 @@ if KH_WEB_SEARCH_BACKEND:
|
||||
except (ImportError, AttributeError) as e:
|
||||
print(f"Error importing {KH_WEB_SEARCH_BACKEND}: {e}")
|
||||
|
||||
REASONING_LIMITS = 2 if KH_DEMO_MODE else 10
|
||||
DEFAULT_SETTING = "(default)"
|
||||
INFO_PANEL_SCALES = {True: 8, False: 4}
|
||||
DEFAULT_QUESTION = (
|
||||
@@ -56,6 +57,17 @@ function() {
|
||||
}
|
||||
"""
|
||||
|
||||
clear_bot_message_selection_js = """
|
||||
function() {
|
||||
var bot_messages = document.querySelectorAll(
|
||||
"div#main-chat-bot div.message-row.bot-row"
|
||||
);
|
||||
bot_messages.forEach(message => {
|
||||
message.classList.remove("text_selection");
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
pdfview_js = """
|
||||
function() {
|
||||
setTimeout(() => {
|
||||
@@ -371,7 +383,7 @@ class ChatPage(BasePage):
|
||||
):
|
||||
with gr.Row(elem_id="quick-setting-labels"):
|
||||
gr.HTML("Reasoning method")
|
||||
gr.HTML("Model", visible=False)
|
||||
gr.HTML("Model", visible=not KH_DEMO_MODE)
|
||||
gr.HTML("Language")
|
||||
|
||||
with gr.Row():
|
||||
@@ -393,7 +405,7 @@ class ChatPage(BasePage):
|
||||
)
|
||||
|
||||
self.reasoning_type = gr.Dropdown(
|
||||
choices=reasoning_setting.choices,
|
||||
choices=reasoning_setting.choices[:REASONING_LIMITS],
|
||||
value=reasoning_setting.value,
|
||||
container=False,
|
||||
show_label=False,
|
||||
@@ -403,7 +415,7 @@ class ChatPage(BasePage):
|
||||
value=model_setting.value,
|
||||
container=False,
|
||||
show_label=False,
|
||||
visible=False,
|
||||
visible=not KH_DEMO_MODE,
|
||||
)
|
||||
self.language = gr.Dropdown(
|
||||
choices=language_setting.choices,
|
||||
@@ -461,7 +473,6 @@ class ChatPage(BasePage):
|
||||
self.chat_panel.text_input,
|
||||
self.chat_panel.chatbot,
|
||||
self._app.user_id,
|
||||
self._user_api_key,
|
||||
self._app.settings_state,
|
||||
self.chat_control.conversation_id,
|
||||
self.chat_control.conversation_rn,
|
||||
@@ -554,16 +565,6 @@ class ChatPage(BasePage):
|
||||
}
|
||||
# chat suggestion toggle
|
||||
chat_event = chat_event.success(**onSuggestChatEvent)
|
||||
# .success(
|
||||
# self.chat_control.persist_chat_suggestions,
|
||||
# inputs=[
|
||||
# self.chat_control.conversation_id,
|
||||
# self.followup_questions,
|
||||
# self._use_suggestion,
|
||||
# self._app.user_id,
|
||||
# ],
|
||||
# show_progress="hidden",
|
||||
# )
|
||||
|
||||
# final data persist
|
||||
if not KH_DEMO_MODE:
|
||||
@@ -758,6 +759,9 @@ class ChatPage(BasePage):
|
||||
).then(
|
||||
lambda: self.toggle_delete(""),
|
||||
outputs=[self.chat_control._new_delete, self.chat_control._delete_confirm],
|
||||
).then(
|
||||
fn=lambda: True,
|
||||
js=clear_bot_message_selection_js,
|
||||
).then(
|
||||
fn=lambda: True,
|
||||
inputs=None,
|
||||
@@ -872,7 +876,6 @@ class ChatPage(BasePage):
|
||||
chat_input,
|
||||
chat_history,
|
||||
user_id,
|
||||
user_api_key,
|
||||
settings,
|
||||
conv_id,
|
||||
conv_name,
|
||||
@@ -881,7 +884,6 @@ class ChatPage(BasePage):
|
||||
):
|
||||
"""Submit a message to the chatbot"""
|
||||
if KH_DEMO_MODE:
|
||||
print("API key", user_api_key)
|
||||
try:
|
||||
import gradiologin as grlogin
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ class ConversationControl(BasePage):
|
||||
except (ImportError, AssertionError):
|
||||
user = None
|
||||
|
||||
if user or user_api_key:
|
||||
if user: # or user_api_key:
|
||||
return [
|
||||
gr.update(visible=True),
|
||||
gr.update(visible=True),
|
||||
|
||||
@@ -127,24 +127,24 @@ with gr.Blocks(
|
||||
variant="primary",
|
||||
elem_id="google-login",
|
||||
)
|
||||
with gr.Accordion(
|
||||
"Or use your own Gemini API key",
|
||||
elem_id="user-api-key-wrapper",
|
||||
open=False,
|
||||
):
|
||||
api_key_input = gr.Textbox(
|
||||
placeholder="API Key",
|
||||
label="Enter your Gemini API key",
|
||||
)
|
||||
api_key_save_btn = gr.Button(
|
||||
"Save",
|
||||
)
|
||||
# with gr.Accordion(
|
||||
# "Or use your own Gemini API key",
|
||||
# elem_id="user-api-key-wrapper",
|
||||
# open=False,
|
||||
# ):
|
||||
# api_key_input = gr.Textbox(
|
||||
# placeholder="API Key",
|
||||
# label="Enter your Gemini API key",
|
||||
# )
|
||||
# api_key_save_btn = gr.Button(
|
||||
# "Save",
|
||||
# )
|
||||
|
||||
api_key_save_btn.click(
|
||||
fn=lambda _: True,
|
||||
inputs=[api_key_input],
|
||||
js=save_api_key_js,
|
||||
)
|
||||
# api_key_save_btn.click(
|
||||
# fn=lambda _: True,
|
||||
# inputs=[api_key_input],
|
||||
# js=save_api_key_js,
|
||||
# )
|
||||
|
||||
app = gr.mount_gradio_app(app, login_demo, path="/login-app")
|
||||
app = gr.mount_gradio_app(
|
||||
|
||||
Reference in New Issue
Block a user