Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,6 +29,30 @@ memory = ConversationBufferWindowMemory(
|
|
29 |
|
30 |
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
from langchain import PromptTemplate
|
33 |
query_text = "when did alice see mad hatter"
|
34 |
|
|
|
29 |
|
30 |
|
31 |
|
32 |
+
|
33 |
+
|
34 |
+
query_text="what did alice say to rabbit"
|
35 |
+
|
36 |
+
# Prepare the DB.
|
37 |
+
#embedding_function = OpenAIEmbeddings() # main
|
38 |
+
|
39 |
+
CHROMA_PATH = "chroma8"
|
40 |
+
# call the chroma generated in a directory
|
41 |
+
db = Chroma(persist_directory=CHROMA_PATH, embedding_function=embeddings)
|
42 |
+
|
43 |
+
# Search the DB for similar documents to the query.
|
44 |
+
results = db.similarity_search_with_relevance_scores(query_text, k=2)
|
45 |
+
if len(results) == 0 or results[0][1] < 0.5:
|
46 |
+
print(f"Unable to find matching results.")
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
from langchain import PromptTemplate
|
57 |
query_text = "when did alice see mad hatter"
|
58 |
|