File size: 1,589 Bytes
10c5258
 
 
85eab21
 
10c5258
 
85eab21
 
10c5258
 
85eab21
 
 
3d4b5b6
10c5258
 
 
 
 
 
 
 
 
85eab21
10c5258
85eab21
 
 
 
 
 
 
 
10c5258
 
4a83326
85eab21
 
 
10c5258
 
 
 
 
4a83326
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import json
from pathlib import Path
from pprint import pprint
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.document_loaders import UnstructuredFileLoader
from langchain.document_loaders.csv_loader import CSVLoader
from langchain.document_loaders import JSONLoader
from langchain.vectorstores.faiss import FAISS
from langchain.embeddings import OpenAIEmbeddings
from langchain.document_loaders import JSONLoader
from langchain.document_loaders import PyPDFLoader
import pickle

# Load Data
#loader = UnstructuredFileLoader("state_of_the_union.txt")
loader = UnstructuredFileLoader("Vendor_feeds.txt")
#loader = UnstructuredFileLoader("_chat.txt")
#csvloader = CSVLoader(file_path='./Vendor_feeds.csv', source_column="Feed_Name", csv_args={
#    'delimiter': ',',
#    'quotechar': '"',
#    'fieldnames': ['Feed_Name', 'Vendor_Name', 'FullDelta', 'Frequency']
#})

#raw_documents = csvloader.load()
raw_documents = loader.load()
#print(raw_documents)

# Split text
text_splitter = RecursiveCharacterTextSplitter()
documents = text_splitter.split_documents(raw_documents)


# Load Data to vectorstore
embeddings = OpenAIEmbeddings()
Vendor_feeds = FAISS.from_documents(documents, embeddings)
#chatstore = FAISS.from_documents(documents, embeddings)
#vectorstore = FAISS.from_documents(documents, embeddings)


# Save vectorstore
with open("Vendor_feeds.pkl", "wb") as f:
     pickle.dump(Vendor_feeds, f)

#with open("chatstore.pkl", "wb") as f:
#     pickle.dump(chatstore, f)
#with open("vectorstore.pkl", "wb") as f:
#    pickle.dump(vectorstore, f)