Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
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 |
-
|
|
|
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)
|