ArturG9 commited on
Commit
2390875
·
verified ·
1 Parent(s): c60308f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -15,27 +15,23 @@ from langchain.chains import create_history_aware_retriever, create_retrieval_ch
15
  from langchain.vectorstores import Chroma
16
  from utills import load_txt_documents , split_docs, load_uploaded_documents,retriever_from_chroma
17
 
18
- # Initialize variables and paths
19
  script_dir = os.path.dirname(os.path.abspath(__file__))
20
  data_path = "data"
21
  model_path = os.path.join(script_dir, 'qwen2-0_5b-instruct-q4_0.gguf')
22
  store = {}
23
 
24
- # Set up HuggingFace embeddings
25
  model_name = "sentence-transformers/all-mpnet-base-v2"
26
  model_kwargs = {'device': 'cpu'}
27
  encode_kwargs = {'normalize_embeddings': True}
28
 
29
- # Use Streamlit's cache to avoid recomputation
30
- @st.cache_resource
31
- def load_embeddings():
32
- return HuggingFaceEmbeddings(
33
- model_name=model_name,
34
- model_kwargs=model_kwargs,
35
- encode_kwargs=encode_kwargs
36
- )
37
 
38
- hf = load_embeddings()
 
 
 
 
39
 
40
 
41
 
 
15
  from langchain.vectorstores import Chroma
16
  from utills import load_txt_documents , split_docs, load_uploaded_documents,retriever_from_chroma
17
 
18
+
19
  script_dir = os.path.dirname(os.path.abspath(__file__))
20
  data_path = "data"
21
  model_path = os.path.join(script_dir, 'qwen2-0_5b-instruct-q4_0.gguf')
22
  store = {}
23
 
24
+
25
  model_name = "sentence-transformers/all-mpnet-base-v2"
26
  model_kwargs = {'device': 'cpu'}
27
  encode_kwargs = {'normalize_embeddings': True}
28
 
 
 
 
 
 
 
 
 
29
 
30
+ hf = HuggingFaceEmbeddings(
31
+ model_name=model_name,
32
+ model_kwargs=model_kwargs,
33
+ encode_kwargs=encode_kwargs
34
+ )
35
 
36
 
37