ngcanh commited on
Commit
a801014
·
verified ·
1 Parent(s): 5e0f6e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -28,20 +28,20 @@ st.set_page_config(page_title="MBAL Chatbot", page_icon="🛡️", layout="wide"
28
 
29
  HF_TOKEN = st.secrets["HF_TOKEN"]
30
 
31
- # Initialize your models, databases, and other components here
32
- # @st.cache_resource
33
- # def init_chroma():
34
- # persist_directory = "chroma_db"
35
- # chroma_client = chromadb.PersistentClient(path=persist_directory)
36
- # chroma_collection = chroma_client.get_or_create_collection("my_collection")
37
- # return chroma_client, chroma_collection
38
-
39
- # @st.cache_resource
40
- # def init_vectorstore():
41
- # persist_directory = "chroma_db"
42
- # embeddings = HuggingFaceEmbeddings()
43
- # vectorstore = Chroma(persist_directory=persist_directory, embedding_function=embeddings, collection_name="my_collection")
44
- # return vectorstore
45
  @st.cache_resource
46
  def setup_vector():
47
  # Đọc dữ liệu từ file Excel
@@ -84,7 +84,8 @@ def setup_vector():
84
  # Initialize components
85
  client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3", token=HF_TOKEN)
86
  chroma_client, chroma_collection = init_chroma()
87
- vectorstore = init_vectorstore()
 
88
 
89
  # Initialize memory buffer
90
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
 
28
 
29
  HF_TOKEN = st.secrets["HF_TOKEN"]
30
 
31
+ Initialize your models, databases, and other components here
32
+ @st.cache_resource
33
+ def init_chroma():
34
+ persist_directory = "chroma_db"
35
+ chroma_client = chromadb.PersistentClient(path=persist_directory)
36
+ chroma_collection = chroma_client.get_or_create_collection("my_collection")
37
+ return chroma_client, chroma_collection
38
+
39
+ @st.cache_resource
40
+ def init_vectorstore():
41
+ persist_directory = "chroma_db"
42
+ embeddings = HuggingFaceEmbeddings()
43
+ vectorstore = Chroma(persist_directory=persist_directory, embedding_function=embeddings, collection_name="my_collection")
44
+ return vectorstore
45
  @st.cache_resource
46
  def setup_vector():
47
  # Đọc dữ liệu từ file Excel
 
84
  # Initialize components
85
  client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3", token=HF_TOKEN)
86
  chroma_client, chroma_collection = init_chroma()
87
+ init_vectorstore()
88
+ vectorstore = setup_vector()
89
 
90
  # Initialize memory buffer
91
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)