Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,17 +27,35 @@ def load_vector_db(zip_file_path, extract_path):
|
|
27 |
st.success("Vector store loaded")
|
28 |
return vectordb
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Function to augment prompt
|
31 |
-
def augment_prompt(query, vectordb):
|
32 |
-
results = vectordb.similarity_search(query, k=
|
33 |
source_knowledge = "\n".join([x.page_content for x in results])
|
34 |
augmented_prompt = f"""
|
35 |
You are an AI assistant. Use the context provided below to answer the question as comprehensively as possible.
|
36 |
-
If the answer is not contained within the context, respond
|
37 |
|
38 |
Context:
|
39 |
{source_knowledge}
|
40 |
|
|
|
|
|
|
|
41 |
Question: {query}
|
42 |
"""
|
43 |
return augmented_prompt
|
|
|
27 |
st.success("Vector store loaded")
|
28 |
return vectordb
|
29 |
|
30 |
+
# # Function to augment prompt
|
31 |
+
# def augment_prompt(query, vectordb):
|
32 |
+
# results = vectordb.similarity_search(query, k=10)
|
33 |
+
# source_knowledge = "\n".join([x.page_content for x in results])
|
34 |
+
# augmented_prompt = f"""
|
35 |
+
# You are an AI assistant. Use the context provided below to answer the question as comprehensively as possible.
|
36 |
+
# If the answer is not contained within the context, respond politely that you cannot provide that information.
|
37 |
+
|
38 |
+
# Context:
|
39 |
+
# {source_knowledge}
|
40 |
+
|
41 |
+
# Question: {query}
|
42 |
+
# """
|
43 |
+
# return augmented_prompt
|
44 |
+
|
45 |
# Function to augment prompt
|
46 |
+
def augment_prompt(query, vectordb, search_results):
|
47 |
+
results = vectordb.similarity_search(query, k=5)
|
48 |
source_knowledge = "\n".join([x.page_content for x in results])
|
49 |
augmented_prompt = f"""
|
50 |
You are an AI assistant. Use the context provided below to answer the question as comprehensively as possible.
|
51 |
+
If the answer is not contained within the context, respond with "I don't know".
|
52 |
|
53 |
Context:
|
54 |
{source_knowledge}
|
55 |
|
56 |
+
Additional Web Search Results:
|
57 |
+
{search_results}
|
58 |
+
|
59 |
Question: {query}
|
60 |
"""
|
61 |
return augmented_prompt
|