jme-datasci commited on
Commit
1f3ab5b
·
1 Parent(s): 9a0c7ad

added ZeroGPU support

Browse files
Files changed (2) hide show
  1. app.py +2 -0
  2. requirements.txt +2 -1
app.py CHANGED
@@ -7,6 +7,7 @@ from tqdm import tqdm
7
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
8
  from langchain_huggingface import HuggingFaceEmbeddings
9
  from langchain_community.vectorstores import FAISS
 
10
 
11
  # Ensure an HF Token is present for gated models (like Llama 3)
12
  HF_TOKEN = os.getenv("HF_TOKEN")
@@ -126,6 +127,7 @@ except Exception as e:
126
  print(f"Error initializing RAG: {e}")
127
 
128
  # --- GRADIO INTERFACE ---
 
129
  def chat_function(message, history):
130
  if rag is None:
131
  return "System Error: The RAG pipeline failed to initialize. Check logs and ensure the 'index/' folder is uploaded."
 
7
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
8
  from langchain_huggingface import HuggingFaceEmbeddings
9
  from langchain_community.vectorstores import FAISS
10
+ import spaces
11
 
12
  # Ensure an HF Token is present for gated models (like Llama 3)
13
  HF_TOKEN = os.getenv("HF_TOKEN")
 
127
  print(f"Error initializing RAG: {e}")
128
 
129
  # --- GRADIO INTERFACE ---
130
+ @spaces.GPU(duration=10)
131
  def chat_function(message, history):
132
  if rag is None:
133
  return "System Error: The RAG pipeline failed to initialize. Check logs and ensure the 'index/' folder is uploaded."
requirements.txt CHANGED
@@ -7,4 +7,5 @@ langchain-community
7
  faiss-gpu
8
  numpy<2
9
  tqdm
10
- sentence_transformers
 
 
7
  faiss-gpu
8
  numpy<2
9
  tqdm
10
+ sentence_transformers
11
+ spaces