File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -99,14 +99,15 @@ def execute(self, state: dict) -> dict:
99
99
)
100
100
embeddings = self .embedder_model
101
101
102
- if self .node_config .get ("cache" , False ):
103
- index = FAISS .from_documents (chunked_docs , embeddings )
104
- folder_name = "cache"
102
+ folder_name = "cache"
105
103
106
- if not os .path .exists (folder_name ):
107
- os .makedirs (folder_name )
104
+ if self .node_config .get ("cache" , False ) and not os .path .exists (folder_name ):
105
+ index = FAISS .from_documents (chunked_docs , embeddings )
106
+ os .makedirs (folder_name )
108
107
109
108
index .save_local (folder_name )
109
+ if self .node_config .get ("cache" , False ) and os .path .exists (folder_name ):
110
+ index = FAISS .load_local (folder_path = folder_name , embeddings = embeddings )
110
111
else :
111
112
index = FAISS .from_documents (chunked_docs , embeddings )
112
113
You can’t perform that action at this time.
0 commit comments