Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,7 @@ with open(credentials_path, "w") as f:
|
|
31 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
|
32 |
|
33 |
# Timeout in seconds for model response
|
34 |
-
TIMEOUT = 60
|
35 |
|
36 |
# Initialize AISuite Client
|
37 |
client = ai.Client()
|
@@ -55,6 +55,7 @@ if len(available_models) < 2:
|
|
55 |
models_state = {}
|
56 |
conversation_state = {}
|
57 |
|
|
|
58 |
# Truncate prompt
|
59 |
def truncate_prompt(prompt, model_alias, models):
|
60 |
model_name = models[model_alias]
|
@@ -64,7 +65,9 @@ def truncate_prompt(prompt, model_alias, models):
|
|
64 |
return prompt
|
65 |
|
66 |
|
67 |
-
def chat_with_models(
|
|
|
|
|
68 |
model_name = models[model_alias]
|
69 |
truncated_input = truncate_prompt(user_input, model_alias, models)
|
70 |
conversation_state.setdefault(model_name, []).append(
|
@@ -293,9 +296,9 @@ def get_leaderboard_data():
|
|
293 |
# Function to enable or disable submit buttons based on textbox content
|
294 |
def toggle_submit_button(text):
|
295 |
if not text or text.strip() == "":
|
296 |
-
return gr.update(interactive=False)
|
297 |
else:
|
298 |
-
return gr.update(interactive=True)
|
299 |
|
300 |
|
301 |
# Gradio Interface
|
@@ -562,7 +565,9 @@ with gr.Blocks() as app:
|
|
562 |
return (
|
563 |
gr.update(visible=False), # Hide the login button
|
564 |
gr.update(interactive=True), # Enable shared_input
|
565 |
-
gr.update(
|
|
|
|
|
566 |
gr.update(interactive=True), # Enable feedback radio buttons
|
567 |
gr.update(interactive=True), # Enable submit_feedback_btn
|
568 |
gr.update(visible=False), # Hide the hint string
|
|
|
31 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
|
32 |
|
33 |
# Timeout in seconds for model response
|
34 |
+
TIMEOUT = 60
|
35 |
|
36 |
# Initialize AISuite Client
|
37 |
client = ai.Client()
|
|
|
55 |
models_state = {}
|
56 |
conversation_state = {}
|
57 |
|
58 |
+
|
59 |
# Truncate prompt
|
60 |
def truncate_prompt(prompt, model_alias, models):
|
61 |
model_name = models[model_alias]
|
|
|
65 |
return prompt
|
66 |
|
67 |
|
68 |
+
def chat_with_models(
|
69 |
+
user_input, model_alias, models, conversation_state, timeout=TIMEOUT
|
70 |
+
):
|
71 |
model_name = models[model_alias]
|
72 |
truncated_input = truncate_prompt(user_input, model_alias, models)
|
73 |
conversation_state.setdefault(model_name, []).append(
|
|
|
296 |
# Function to enable or disable submit buttons based on textbox content
|
297 |
def toggle_submit_button(text):
|
298 |
if not text or text.strip() == "":
|
299 |
+
return gr.update(interactive=False) # Disable the button
|
300 |
else:
|
301 |
+
return gr.update(interactive=True) # Enable the button
|
302 |
|
303 |
|
304 |
# Gradio Interface
|
|
|
565 |
return (
|
566 |
gr.update(visible=False), # Hide the login button
|
567 |
gr.update(interactive=True), # Enable shared_input
|
568 |
+
gr.update(
|
569 |
+
interactive=False
|
570 |
+
), # Keep send_first button disabled initially
|
571 |
gr.update(interactive=True), # Enable feedback radio buttons
|
572 |
gr.update(interactive=True), # Enable submit_feedback_btn
|
573 |
gr.update(visible=False), # Hide the hint string
|