clui commited on
Commit
d6688a2
verified
1 Parent(s): c1f3724

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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
- # Utw贸rz indeks z vector store
15
  index = VectorStoreIndex.from_vector_store(vector_store, embed_model=embed_model)
16
 
17
- # Zamiast query_engine z LLM, u偶yjemy retrievera bez LLM
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
- # Pobierz najtrafniejsze dokumenty (np. top 3)
36
  results = retriever.retrieve(input)
37
- # Po艂膮cz teksty wynik贸w w jedn膮 odpowied藕
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})