Update app.py
Browse files
app.py
CHANGED
@@ -8,15 +8,19 @@ import streamlit as st
|
|
8 |
embedding_function = SentenceTransformerEmbeddings(model_name="all-mpnet-base-v2")
|
9 |
chdb = Chroma(persist_directory="./chroma_db_info", embedding_function=embedding_function)
|
10 |
|
11 |
-
|
|
|
12 |
if text:
|
13 |
-
docs = chdb.similarity_search_with_score(
|
14 |
docnum = len(docs)
|
15 |
index = 0
|
16 |
-
ret =
|
17 |
for ii in range(docnum):
|
18 |
doc = docs[ii][0]
|
19 |
score = docs[ii][1]
|
20 |
ret += f"Return {index} ({score:.4f}) :\n{doc.page_content}\n"
|
|
|
|
|
|
|
21 |
st.text(ret)
|
22 |
|
|
|
8 |
embedding_function = SentenceTransformerEmbeddings(model_name="all-mpnet-base-v2")
|
9 |
chdb = Chroma(persist_directory="./chroma_db_info", embedding_function=embedding_function)
|
10 |
|
11 |
+
query = st.text_area("enter text")
|
12 |
+
disnum = 3
|
13 |
if text:
|
14 |
+
docs = chdb.similarity_search_with_score(query)
|
15 |
docnum = len(docs)
|
16 |
index = 0
|
17 |
+
ret = f"Query:{query}\n"
|
18 |
for ii in range(docnum):
|
19 |
doc = docs[ii][0]
|
20 |
score = docs[ii][1]
|
21 |
ret += f"Return {index} ({score:.4f}) :\n{doc.page_content}\n"
|
22 |
+
index += 1
|
23 |
+
if index > disnum:
|
24 |
+
break
|
25 |
st.text(ret)
|
26 |
|