drguilhermeapolinario
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ client = Groq(
|
|
42 |
api_key=st.secrets["GROQ_API_KEY"],
|
43 |
)
|
44 |
|
45 |
-
|
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 |
-
|
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=[
|