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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -3,7 +3,7 @@ import os
3
  from http.cookies import SimpleCookie
4
  from dotenv import load_dotenv
5
  from llama_index.core import StorageContext, load_index_from_storage, VectorStoreIndex, SimpleDirectoryReader, ChatPromptTemplate, Settings
6
- from llama_index.llms.huggingface import HuggingFaceInferenceAPI
7
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
8
  import random
9
  import datetime
@@ -11,7 +11,7 @@ import datetime
11
  # Load environment variables
12
  load_dotenv()
13
 
14
- # Configure the Llama index settings
15
  Settings.llm = HuggingFaceInferenceAPI(
16
  model_name="meta-llama/Meta-Llama-3-8B-Instruct",
17
  tokenizer_name="meta-llama/Meta-Llama-3-8B-Instruct",
@@ -150,8 +150,14 @@ with gr.Blocks(css=css) as demo:
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()
 
3
  from http.cookies import SimpleCookie
4
  from dotenv import load_dotenv
5
  from llama_index.core import StorageContext, load_index_from_storage, VectorStoreIndex, SimpleDirectoryReader, ChatPromptTemplate, Settings
6
+ from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI # Updated import
7
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
8
  import random
9
  import datetime
 
11
  # Load environment variables
12
  load_dotenv()
13
 
14
+ # Configure the Llama index settings with updated API
15
  Settings.llm = HuggingFaceInferenceAPI(
16
  model_name="meta-llama/Meta-Llama-3-8B-Instruct",
17
  tokenizer_name="meta-llama/Meta-Llama-3-8B-Instruct",
 
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 JavaScript for redirect
154
+ gr.HTML("""
155
+ <script>
156
+ document.querySelector('button').addEventListener('click', function() {
157
+ window.location.href = 'https://redfernstech.com/chat-bot-test';
158
+ });
159
+ </script>
160
+ """)
161
 
162
  # Launch the Gradio interface
163
  demo.launch()