drguilhermeapolinario commited on
Commit
3998655
·
verified ·
1 Parent(s): f9f57b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -37,7 +37,6 @@ def load_embedding_model():
37
 
38
  model = load_embedding_model()
39
 
40
- # Inicialização do cliente Groq
41
  client = Groq(
42
  api_key=st.secrets["GROQ_API_KEY"],
43
  )
@@ -48,12 +47,13 @@ def load_index_and_embeddings(index_file: str, embeddings_file: str):
48
  embeddings = np.load(embeddings_file)
49
  return index, embeddings
50
 
 
51
  def search(query: str, index, embeddings: np.ndarray, chunks: list, k: int = 5):
52
  query_vector = model.encode([query])
53
  distances, indices = index.search(query_vector.astype('float32'), k)
54
  return [chunks[i] for i in indices[0]]
55
 
56
- @st.cache_resource
57
  def query_groq(prompt, client):
58
  chat_completion = client.chat.completions.create(
59
  messages=[
 
37
 
38
  model = load_embedding_model()
39
 
 
40
  client = Groq(
41
  api_key=st.secrets["GROQ_API_KEY"],
42
  )
 
47
  embeddings = np.load(embeddings_file)
48
  return index, embeddings
49
 
50
+ @st.cache_resource
51
  def search(query: str, index, embeddings: np.ndarray, chunks: list, k: int = 5):
52
  query_vector = model.encode([query])
53
  distances, indices = index.search(query_vector.astype('float32'), k)
54
  return [chunks[i] for i in indices[0]]
55
 
56
+
57
  def query_groq(prompt, client):
58
  chat_completion = client.chat.completions.create(
59
  messages=[