Engineer786 commited on
Commit
b4b1755
·
verified ·
1 Parent(s): 5230b46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -7,11 +7,11 @@ import faiss
7
  from groq import Groq
8
 
9
  # Fetch API key from environment variable
10
- API_KEY = os.environ.get('GroqApi')
11
 
12
- # Initialize variables
13
- INDEX = None
14
  CHUNKS = None
 
15
  MODEL = None
16
 
17
  # Function to scrape tariff data
@@ -73,8 +73,8 @@ url = st.text_input("Enter Tariff Data URL", "https://iesco.com.pk/index.php/cus
73
  if st.button("Process Tariff Data"):
74
  with st.spinner("Extracting and processing data..."):
75
  try:
 
76
  text = scrape_tariff_data(url)
77
- global CHUNKS, INDEX, MODEL
78
  CHUNKS = chunk_text(text)
79
  INDEX, embeddings, MODEL = create_faiss_index(CHUNKS)
80
  st.success("Data processed and indexed!")
 
7
  from groq import Groq
8
 
9
  # Fetch API key from environment variable
10
+ API_KEY = os.environ.get("GroqApi")
11
 
12
+ # Global variables for index, chunks, and model
 
13
  CHUNKS = None
14
+ INDEX = None
15
  MODEL = None
16
 
17
  # Function to scrape tariff data
 
73
  if st.button("Process Tariff Data"):
74
  with st.spinner("Extracting and processing data..."):
75
  try:
76
+ global CHUNKS, INDEX, MODEL # Ensure global declaration is at the top
77
  text = scrape_tariff_data(url)
 
78
  CHUNKS = chunk_text(text)
79
  INDEX, embeddings, MODEL = create_faiss_index(CHUNKS)
80
  st.success("Data processed and indexed!")