Srinivasulu kethanaboina commited on
Commit
0e835de
1 Parent(s): 0f7bc71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -7,7 +7,6 @@ from llama_index.llms.huggingface import HuggingFaceInferenceAPI
7
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
8
  import random
9
  import datetime
10
- import webbrowser # To handle the redirect
11
 
12
  # Load environment variables
13
  load_dotenv()
@@ -93,8 +92,6 @@ def handle_query(query, cookies=None):
93
  # Define the button click function
94
  def retrieve_history_and_redirect():
95
  # Here you can retrieve the chat history if necessary
96
- # Return a confirmation message for now
97
- webbrowser.open("https://redfernstech.com/chat-bot-test") # Redirect to the target URL
98
  return "History retrieved. Redirecting to the chat test page..."
99
 
100
  # Define your Gradio chat interface function
@@ -147,11 +144,14 @@ with gr.Blocks(css=css) as demo:
147
  # Button to retrieve history and redirect
148
  redirect_button = gr.Button("Retrieve History & Redirect")
149
 
150
- # Use a gr.Textbox or gr.HTML as output for the button
151
  redirect_message = gr.Textbox(label="Status", interactive=False)
152
-
153
  # Connect the button with the function, and output the status message
154
  redirect_button.click(fn=retrieve_history_and_redirect, inputs=[], outputs=redirect_message)
155
 
 
 
 
156
  # Launch the Gradio interface
157
  demo.launch()
 
7
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
8
  import random
9
  import datetime
 
10
 
11
  # Load environment variables
12
  load_dotenv()
 
92
  # Define the button click function
93
  def retrieve_history_and_redirect():
94
  # Here you can retrieve the chat history if necessary
 
 
95
  return "History retrieved. Redirecting to the chat test page..."
96
 
97
  # Define your Gradio chat interface function
 
144
  # Button to retrieve history and redirect
145
  redirect_button = gr.Button("Retrieve History & Redirect")
146
 
147
+ # Use a gr.Textbox as output for the button to display the status message
148
  redirect_message = gr.Textbox(label="Status", interactive=False)
149
+
150
  # Connect the button with the function, and output the status message
151
  redirect_button.click(fn=retrieve_history_and_redirect, inputs=[], outputs=redirect_message)
152
 
153
+ # Add a JavaScript redirect after button click
154
+ redirect_button.click(None, [], None, _js="() => { window.location.href = 'https://redfernstech.com/chat-bot-test'; }")
155
+
156
  # Launch the Gradio interface
157
  demo.launch()