Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def load_embeddings_and_faiss():
|
|
27 |
|
28 |
return faiss_index, question_embeddings
|
29 |
|
30 |
-
def retrieve_answer(question, faiss_index, embedding_model, answers, threshold=0.2
|
31 |
question_embedding = embedding_model.embed_query(question)
|
32 |
distances, indices = faiss_index.search(np.array([question_embedding]), k=1)
|
33 |
|
@@ -59,7 +59,7 @@ def chatbot(user_input):
|
|
59 |
start_time = time.time() # Start timer
|
60 |
|
61 |
log_output.write("Retrieving answer from FAISS...\n")
|
62 |
-
response_text = retrieve_answer(user_input, faiss_index, embedding_model, answers, threshold=0.3
|
63 |
|
64 |
if response_text == "No good match found in dataset. Using GPT-4o-mini to generate an answer.":
|
65 |
log_output.write("No good match found in dataset. Using GPT-4o-mini to generate an answer.\n")
|
|
|
27 |
|
28 |
return faiss_index, question_embeddings
|
29 |
|
30 |
+
def retrieve_answer(question, faiss_index, embedding_model, answers, log_output, threshold=0.2):
|
31 |
question_embedding = embedding_model.embed_query(question)
|
32 |
distances, indices = faiss_index.search(np.array([question_embedding]), k=1)
|
33 |
|
|
|
59 |
start_time = time.time() # Start timer
|
60 |
|
61 |
log_output.write("Retrieving answer from FAISS...\n")
|
62 |
+
response_text = retrieve_answer(user_input, faiss_index, embedding_model, answers, log_output, threshold=0.3)
|
63 |
|
64 |
if response_text == "No good match found in dataset. Using GPT-4o-mini to generate an answer.":
|
65 |
log_output.write("No good match found in dataset. Using GPT-4o-mini to generate an answer.\n")
|