ArturG9 commited on
Commit
ba5c96d
·
verified ·
1 Parent(s): bccf29a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -23
app.py CHANGED
@@ -30,39 +30,19 @@ def load_embeddings():
30
 
31
  hf = load_embeddings()
32
 
33
- @st.cache_data
34
- def load_txt_documents(data_path):
35
- documents = []
36
- for filename in os.listdir(data_path):
37
- if filename.endswith('.txt'):
38
- file_path = os.path.join(data_path, filename)
39
- documents.extend(TextLoader(file_path).load())
40
- return documents
41
 
42
- @st.cache_data
43
- def load_uploaded_documents(uploaded_files):
44
- documents = []
45
- for uploaded_file in uploaded_files:
46
- content = uploaded_file.read().decode("utf-8")
47
- documents.append({"content": content, "filename": uploaded_file.name})
48
- return documents
49
 
50
 
51
 
52
  documents = load_documents(data_path)
53
  docs = split_docs(documents, 450, 20)
54
 
55
- @st.cache_resource
56
- def create_chroma_db(docs, hf):
57
- return Chroma(docs, hf)
58
 
59
- chroma_db = create_chroma_db(docs, hf)
60
 
61
- @st.cache_resource
62
- def create_retriever(chroma_db):
63
- return mmr_retriever(chroma_db, "mmr", 6)
64
 
65
- retriever = create_retriever(chroma_db)
66
 
67
  # Set up LlamaCpp model
68
  callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
 
30
 
31
  hf = load_embeddings()
32
 
 
 
 
 
 
 
 
 
33
 
 
 
 
 
 
 
 
34
 
35
 
36
 
37
  documents = load_documents(data_path)
38
  docs = split_docs(documents, 450, 20)
39
 
 
 
 
40
 
 
41
 
42
+ chroma_db = chroma_db(docs, hf)
43
+
 
44
 
45
+ retriever = retriever_from_chroma(chroma_db,"mmr", 6)
46
 
47
  # Set up LlamaCpp model
48
  callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])