Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,11 +11,11 @@ chroma_collection = db.get_or_create_collection("zalacznik_nr12")
|
|
| 11 |
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
|
| 12 |
embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
|
| 13 |
|
| 14 |
-
#
|
| 15 |
index = VectorStoreIndex.from_vector_store(vector_store, embed_model=embed_model)
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
retriever = index.as_retriever()
|
| 19 |
|
| 20 |
if "messages" not in st.session_state:
|
| 21 |
st.session_state.messages = [{"role": "assistant", "content": "Zadaj mi pytanie..."}]
|
|
@@ -32,9 +32,9 @@ if input := st.chat_input():
|
|
| 32 |
if st.session_state.messages[-1]["role"] != "assistant":
|
| 33 |
with st.chat_message("assistant"):
|
| 34 |
with st.spinner("Czekaj, trwa wyszukiwanie..."):
|
| 35 |
-
|
| 36 |
results = retriever.retrieve(input)
|
| 37 |
-
|
| 38 |
content = "\n\n---\n\n".join([doc.text for doc in results])
|
| 39 |
st.write(content)
|
| 40 |
st.session_state.messages.append({"role": "assistant", "content": content})
|
|
|
|
| 11 |
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
|
| 12 |
embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
|
| 13 |
|
| 14 |
+
# Indeks z vector store
|
| 15 |
index = VectorStoreIndex.from_vector_store(vector_store, embed_model=embed_model)
|
| 16 |
|
| 17 |
+
# Retriever bez LLM
|
| 18 |
+
retriever = index.as_retriever(similarity_top_k=1)
|
| 19 |
|
| 20 |
if "messages" not in st.session_state:
|
| 21 |
st.session_state.messages = [{"role": "assistant", "content": "Zadaj mi pytanie..."}]
|
|
|
|
| 32 |
if st.session_state.messages[-1]["role"] != "assistant":
|
| 33 |
with st.chat_message("assistant"):
|
| 34 |
with st.spinner("Czekaj, trwa wyszukiwanie..."):
|
| 35 |
+
|
| 36 |
results = retriever.retrieve(input)
|
| 37 |
+
|
| 38 |
content = "\n\n---\n\n".join([doc.text for doc in results])
|
| 39 |
st.write(content)
|
| 40 |
st.session_state.messages.append({"role": "assistant", "content": content})
|