drguilhermeapolinario commited on
Commit
d4132e7
·
verified ·
1 Parent(s): 9165e74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -42,7 +42,7 @@ client = Groq(
42
  api_key=st.secrets["GROQ_API_KEY"],
43
  )
44
 
45
- # Funções auxiliares
46
  def load_index_and_embeddings(index_file: str, embeddings_file: str):
47
  index = faiss.read_index(index_file)
48
  embeddings = np.load(embeddings_file)
@@ -53,7 +53,7 @@ def search(query: str, index, embeddings: np.ndarray, chunks: list, k: int = 5):
53
  distances, indices = index.search(query_vector.astype('float32'), k)
54
  return [chunks[i] for i in indices[0]]
55
 
56
- # Função para chamar a API da Groq
57
  def query_groq(prompt, client):
58
  chat_completion = client.chat.completions.create(
59
  messages=[
 
42
  api_key=st.secrets["GROQ_API_KEY"],
43
  )
44
 
45
+ @st.cache_resource
46
  def load_index_and_embeddings(index_file: str, embeddings_file: str):
47
  index = faiss.read_index(index_file)
48
  embeddings = np.load(embeddings_file)
 
53
  distances, indices = index.search(query_vector.astype('float32'), k)
54
  return [chunks[i] for i in indices[0]]
55
 
56
+ @st.cache_data
57
  def query_groq(prompt, client):
58
  chat_completion = client.chat.completions.create(
59
  messages=[