Spaces:
Running
Running
Update vlog4chat.py
Browse files- vlog4chat.py +3 -7
vlog4chat.py
CHANGED
@@ -153,13 +153,9 @@ class Vlogger4chat :
|
|
153 |
print("The log file is empty or could not be loaded.")
|
154 |
return False # 如果 raw_documents 为空或所有内容都为空白,直接返回
|
155 |
# Split text
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
pkl_path = os.path.join(self.data_dir, f"{video_id}.pkl")
|
160 |
-
with open(pkl_path, 'rb') as f:
|
161 |
-
self.vector_storage = pickle.load(f)
|
162 |
-
|
163 |
self.chain = ConversationalRetrievalChain.from_llm(self.llm, self.vector_storage.as_retriever(), return_source_documents=True)
|
164 |
return True
|
165 |
return False
|
|
|
153 |
print("The log file is empty or could not be loaded.")
|
154 |
return False # 如果 raw_documents 为空或所有内容都为空白,直接返回
|
155 |
# Split text
|
156 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50)
|
157 |
+
chunks = text_splitter.split_documents(raw_documents)
|
158 |
+
self.vector_storage = FAISS.from_documents(chunks, self.my_embedding)
|
|
|
|
|
|
|
|
|
159 |
self.chain = ConversationalRetrievalChain.from_llm(self.llm, self.vector_storage.as_retriever(), return_source_documents=True)
|
160 |
return True
|
161 |
return False
|