LVKinyanjui commited on
Commit
6dcc394
1 Parent(s): f663c35

Added a text box which triggers a vector database query that returns matches

Browse files
app.py CHANGED
@@ -11,7 +11,7 @@ def initdb():
11
 
12
  st.write("## Local RAG \n Get Insights from your documents")
13
 
14
- file = st.file_uploader("Upload your Document Here", type=['pdf'])
15
 
16
  if file is not None:
17
  # Read file as bytes and save it.
@@ -30,5 +30,21 @@ if file is not None:
30
  collection.add(documents=texts, ids=text_ids)
31
  st.write("Succesfully uploaded document to database.")
32
 
 
 
 
 
 
33
 
 
 
 
 
 
 
34
 
 
 
 
 
 
 
11
 
12
  st.write("## Local RAG \n Get Insights from your documents")
13
 
14
+ file = st.file_uploader("Upload your Document Here to Query", type=['pdf'])
15
 
16
  if file is not None:
17
  # Read file as bytes and save it.
 
30
  collection.add(documents=texts, ids=text_ids)
31
  st.write("Succesfully uploaded document to database.")
32
 
33
+ # QUERY AREA
34
+ query = st.text_input(
35
+ "Enter your query",
36
+ # disabled=st.session_state.disabled,
37
+ )
38
 
39
+ if query != "":
40
+ query_results = collection.query(
41
+ query_texts=[query, ],
42
+ n_results=5,
43
+ include=["documents", ]
44
+ )
45
 
46
+ query_text = [" ".join([str(element) for element in inner_list])
47
+ for inner_list in query_results["documents"]][0]
48
+
49
+ st.write("Database Query Matches")
50
+ st.markdown(query_text)
ollama-docker/Dockerfile ADDED
File without changes
ollama-docker/compose.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ ollama-server:
3
+ build:
4
+ context: .
5
+ volumes:
6
+ - ollama:/root/.ollama
7
+ ports:
8
+ - 11434:11434
requirements.txt CHANGED
@@ -1,5 +1,3 @@
1
  chromadb==0.5.5
2
  pymupdf==1.24.9
3
  streamlit==1.38.0
4
- transformers
5
- torch
 
1
  chromadb==0.5.5
2
  pymupdf==1.24.9
3
  streamlit==1.38.0