Shaileshshantaram Kadam commited on
Commit
10c5258
·
1 Parent(s): 3d4b5b6

Updated Vectorstore

Browse files
Files changed (8) hide show
  1. Vendor_feeds.csv +56 -0
  2. Vendor_feeds.pkl +3 -0
  3. Vendor_feeds.txt +56 -0
  4. app.py +4 -4
  5. chatstore.pkl +2 -2
  6. cli_app.py +3 -3
  7. ingest_data.py +24 -4
  8. query_data.py +38 -11
Vendor_feeds.csv ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Feed_Name,Vendor_Name,Full/Delta,Frequency
2
+ Category Tree,CATALYST,Full,Daily
3
+ Category Tree,BLOOMREACH,Full + Delta,Daily + Hourly
4
+ Category Tree,COHERENTPATH,Full + Delta,Daily + Hourly
5
+ Category Tree,STYLYZE,Full + Delta,Daily + Hourly
6
+ Category Tree,EVERGAGE,Full + Delta,Daily + Hourly
7
+ Google Sku Catalog(GMC),CHEETAHMAIL,Full,Daily
8
+ Google Sku Catalog(GMC),BORDERFREE,Full,Daily
9
+ Google Sku Catalog(GMC),COHERENTPATH,Full,Daily
10
+ Google Sku Catalog(GMC),CRITEO,Full,Daily
11
+ Google Sku Catalog(GMC),CURALATE,Full,Daily
12
+ Google Sku Catalog(GMC),TRUEFIT,Full,Daily
13
+ Google Sku Catalog(GMC),STYLYZE,Full,Daily
14
+ Google Sku Catalog(GMC),RTB House,Full,Daily
15
+ Google Sku Catalog(GMC),IPROSPECT,Full,Daily
16
+ Google Sku Catalog(GMC),SHOPRUNNER,Full,Daily
17
+ Inventory,BLOOMREACH,Full + Delta,Daily + Hourly
18
+ Inventory,COHERENTPATH,Full + Delta,Daily + Hourly
19
+ Inventory,ANTUIT,Full,Daily
20
+ Inventory,IPROSPECT,Full + Delta,Daily + Hourly
21
+ Inventory,STYLYZE,Full + Delta,Daily + Hourly
22
+ Inventory,EVERGAGE,Full + Delta,Daily + Hourly
23
+ Inventory,SHOPRUNNER,Full + Delta,Daily + Hourly
24
+ Sku Image,BLOOMREACH,Full + Delta,Daily + Hourly
25
+ Sku Image,STYLYZE,Full + Delta,Daily + Hourly
26
+ Sku Image,COHERENTPATH,Full + Delta,Daily + Hourly
27
+ Sku Image,IPROSPECT,Full,Daily
28
+ NMG Sku Catalog,BLOOMREACH,Full,Daily
29
+ NMG Sku Catalog,STYLYZE,Full + Delta,Daily + Hourly
30
+ NMG Sku Catalog,ANTUIT,Full,Daily
31
+ NMG Sku Catalog,COHERENTPATH,Full + Delta,Daily + Hourly
32
+ NMG Sku Catalog,EVERGAGE,Full + Delta,Daily + Hourly
33
+ NMG Sku Catalog(Master),STYLYZE,Full,Daily
34
+ Group Catalog,BLOOMREACH,Full + Delta,Daily + Hourly
35
+ Group Catalog,STYLYZE,Full + Delta,Daily + Hourly
36
+ Group Catalog,COHERENTPATH,Full + Delta,Daily + Hourly
37
+ Pricing and Promo,BLOOMREACH,Full + Delta,Daily + Hourly
38
+ Pricing and Promo,COHERENTPATH,Full + Delta,Daily + Hourly
39
+ Pricing and Promo,CRITEO,Full + Delta,Daily + Hourly
40
+ Pricing and Promo,RTB House,Full + Delta,Daily + Hourly
41
+ Pricing and Promo,IPROSPECT,Full + Delta,Daily + Hourly
42
+ Pricing and Promo,STYLESAGE,Full,Daily
43
+ Pricing and Promo,STYLYZE,Full + Delta,Daily + Hourly
44
+ Pricing and Promo,EVERGAGE,Full + Delta,Daily + Hourly
45
+ Pricing and Promo,SHOPRUNNER,Full,Daily
46
+ Product Attributes,BLOOMREACH,Full,Daily
47
+ Product Attributes,COHERENTPATH,Full,Daily
48
+ Product Attributes,EVERGAGE,Full,Daily
49
+ Store Location,BLOOMREACH,Full,Daily
50
+ Store Location,COHERENTPATH,Full,Daily
51
+ Store Location,IPROSPECT,Full,Daily
52
+ GMC(with history),TRUEFIT,Full,Daily
53
+ GMC(with history),STYLESAGE,Full,Daily
54
+ GMC(with history),SHOPRUNNER,Full,Daily
55
+ GMC(with history),FACEBOOK,Full,Daily
56
+ GMC Affiliate,LINKSHARE,Full,Daily
Vendor_feeds.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5bae34a3b46c58809f52280052734b37161fa052c03384d68c4671039322da16
3
+ size 9758
Vendor_feeds.txt ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Feed_Name,Vendor_Name,Full/Delta,Frequency
2
+ Category_Tree,CATALYST,Full,Daily
3
+ Category_Tree,BLOOMREACH,Full + Delta,Daily + Hourly
4
+ Category_Tree,COHERENTPATH,Full + Delta,Daily + Hourly
5
+ Category_Tree,STYLYZE,Full + Delta,Daily + Hourly
6
+ Category_Tree,EVERGAGE,Full + Delta,Daily + Hourly
7
+ Google_Sku_Catalog(GMC),CHEETAHMAIL,Full,Daily
8
+ Google_Sku_Catalog(GMC),BORDERFREE,Full,Daily
9
+ Google_Sku_Catalog(GMC),COHERENTPATH,Full,Daily
10
+ Google_Sku_Catalog(GMC),CRITEO,Full,Daily
11
+ Google_Sku_Catalog(GMC),CURALATE,Full,Daily
12
+ Google_Sku_Catalog(GMC),TRUEFIT,Full,Daily
13
+ Google_Sku_Catalog(GMC),STYLYZE,Full,Daily
14
+ Google_Sku_Catalog(GMC),RTB House,Full,Daily
15
+ Google_Sku_Catalog(GMC),IPROSPECT,Full,Daily
16
+ Google_Sku_Catalog(GMC),SHOPRUNNER,Full,Daily
17
+ Inventory,BLOOMREACH,Full + Delta,Daily + Hourly
18
+ Inventory,COHERENTPATH,Full + Delta,Daily + Hourly
19
+ Inventory,ANTUIT,Full,Daily
20
+ Inventory,IPROSPECT,Full + Delta,Daily + Hourly
21
+ Inventory,STYLYZE,Full + Delta,Daily + Hourly
22
+ Inventory,EVERGAGE,Full + Delta,Daily + Hourly
23
+ Inventory,SHOPRUNNER,Full + Delta,Daily + Hourly
24
+ Sku_Image,BLOOMREACH,Full + Delta,Daily + Hourly
25
+ Sku_Image,STYLYZE,Full + Delta,Daily + Hourly
26
+ Sku_Image,COHERENTPATH,Full + Delta,Daily + Hourly
27
+ Sku_Image,IPROSPECT,Full,Daily
28
+ NMG_Sku_Catalog,BLOOMREACH,Full,Daily
29
+ NMG_Sku_Catalog,STYLYZE,Full + Delta,Daily + Hourly
30
+ NMG_Sku_Catalog,ANTUIT,Full,Daily
31
+ NMG_Sku_Catalog,COHERENTPATH,Full + Delta,Daily + Hourly
32
+ NMG_Sku_Catalog,EVERGAGE,Full + Delta,Daily + Hourly
33
+ NMG_Sku_Catalog(Master),STYLYZE,Full,Daily
34
+ Group_Catalog,BLOOMREACH,Full + Delta,Daily + Hourly
35
+ Group_Catalog,STYLYZE,Full + Delta,Daily + Hourly
36
+ Group_Catalog,COHERENTPATH,Full + Delta,Daily + Hourly
37
+ Pricing_and_Promo,BLOOMREACH,Full + Delta,Daily + Hourly
38
+ Pricing_and_Promo,COHERENTPATH,Full + Delta,Daily + Hourly
39
+ Pricing_and_Promo,CRITEO,Full + Delta,Daily + Hourly
40
+ Pricing_and_Promo,RTB House,Full + Delta,Daily + Hourly
41
+ Pricing_and_Promo,IPROSPECT,Full + Delta,Daily + Hourly
42
+ Pricing_and_Promo,STYLESAGE,Full,Daily
43
+ Pricing_and_Promo,STYLYZE,Full + Delta,Daily + Hourly
44
+ Pricing_and_Promo,EVERGAGE,Full + Delta,Daily + Hourly
45
+ Pricing_and_Promo,SHOPRUNNER,Full,Daily
46
+ Product_Attributes,BLOOMREACH,Full,Daily
47
+ Product_Attributes,COHERENTPATH,Full,Daily
48
+ Product_Attributes,EVERGAGE,Full,Daily
49
+ Store_Location,BLOOMREACH,Full,Daily
50
+ Store_Location,COHERENTPATH,Full,Daily
51
+ Store_Location,IPROSPECT,Full,Daily
52
+ GMC(with history),TRUEFIT,Full,Daily
53
+ GMC(with history),STYLESAGE,Full,Daily
54
+ GMC(with history),SHOPRUNNER,Full,Daily
55
+ GMC(with history),FACEBOOK,Full,Daily
56
+ GMC_Affiliate,LINKSHARE,Full,Daily
app.py CHANGED
@@ -53,7 +53,7 @@ block = gr.Blocks(css=".gradio-container {background-color: lightgray}")
53
 
54
  with block:
55
  with gr.Row():
56
- gr.Markdown("<h3><center>Chat-Your-Data (State-of-the-Union)</center></h3>")
57
 
58
  openai_api_key_textbox = gr.Textbox(
59
  placeholder="Paste your OpenAI API key (sk-...)",
@@ -74,9 +74,9 @@ with block:
74
 
75
  gr.Examples(
76
  examples=[
77
- "What did the president say about Kentaji Brown Jackson",
78
- "Did he mention Stephen Breyer?",
79
- "What was his stance on Ukraine",
80
  ],
81
  inputs=message,
82
  )
 
53
 
54
  with block:
55
  with gr.Row():
56
+ gr.Markdown("<h3><center>ICC-Bot (Answers related to feeds)</center></h3>")
57
 
58
  openai_api_key_textbox = gr.Textbox(
59
  placeholder="Paste your OpenAI API key (sk-...)",
 
74
 
75
  gr.Examples(
76
  examples=[
77
+ "List the feeds in the file",
78
+ "list the row in file that have Antuit as the vendor name",
79
+ "list only full and daily feeds",
80
  ],
81
  inputs=message,
82
  )
chatstore.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:650abfa029dbc8c6bc47227b5c7a1f6dc8b069c0c840061c88687357df9dedc3
3
- size 11991824
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12af449e01ef03e3f0a0017a086d352b36ae79d1a32878281fbfe3615e376ecf
3
+ size 12231409
cli_app.py CHANGED
@@ -1,10 +1,10 @@
1
  import pickle
2
  from query_data import get_chain
3
 
4
-
5
  if __name__ == "__main__":
6
- with open("chatstore.pkl", "rb") as f:
7
- #with open("vectorstore.pkl", "rb") as f:
 
8
  vectorstore = pickle.load(f)
9
  qa_chain = get_chain(vectorstore)
10
  chat_history = []
 
1
  import pickle
2
  from query_data import get_chain
3
 
 
4
  if __name__ == "__main__":
5
+ ##with open("chatstore.pkl", "rb") as f:
6
+ with open("Vendor_feeds.pkl", "rb") as f:
7
+ ##with open("vectorstore.pkl", "rb") as f:
8
  vectorstore = pickle.load(f)
9
  qa_chain = get_chain(vectorstore)
10
  chat_history = []
ingest_data.py CHANGED
@@ -1,13 +1,29 @@
 
 
 
1
  from langchain.text_splitter import RecursiveCharacterTextSplitter
2
  from langchain.document_loaders import UnstructuredFileLoader
 
 
3
  from langchain.vectorstores.faiss import FAISS
4
  from langchain.embeddings import OpenAIEmbeddings
 
 
5
  import pickle
6
 
7
  # Load Data
8
  #loader = UnstructuredFileLoader("state_of_the_union.txt")
9
- loader = UnstructuredFileLoader("_chat.txt")
 
 
 
 
 
 
 
 
10
  raw_documents = loader.load()
 
11
 
12
  # Split text
13
  text_splitter = RecursiveCharacterTextSplitter()
@@ -16,12 +32,16 @@ documents = text_splitter.split_documents(raw_documents)
16
 
17
  # Load Data to vectorstore
18
  embeddings = OpenAIEmbeddings()
19
- chatstore = FAISS.from_documents(documents, embeddings)
 
20
  #vectorstore = FAISS.from_documents(documents, embeddings)
21
 
22
 
23
  # Save vectorstore
24
- with open("chatstore.pkl", "wb") as f:
25
- pickle.dump(chatstore, f)
 
 
 
26
  #with open("vectorstore.pkl", "wb") as f:
27
  # pickle.dump(vectorstore, f)
 
1
+ import json
2
+ from pathlib import Path
3
+ from pprint import pprint
4
  from langchain.text_splitter import RecursiveCharacterTextSplitter
5
  from langchain.document_loaders import UnstructuredFileLoader
6
+ from langchain.document_loaders.csv_loader import CSVLoader
7
+ from langchain.document_loaders import JSONLoader
8
  from langchain.vectorstores.faiss import FAISS
9
  from langchain.embeddings import OpenAIEmbeddings
10
+ from langchain.document_loaders import JSONLoader
11
+ from langchain.document_loaders import PyPDFLoader
12
  import pickle
13
 
14
  # Load Data
15
  #loader = UnstructuredFileLoader("state_of_the_union.txt")
16
+ loader = UnstructuredFileLoader("Vendor_feeds.txt")
17
+ #loader = UnstructuredFileLoader("_chat.txt")
18
+ #csvloader = CSVLoader(file_path='./Vendor_feeds.csv', source_column="Feed_Name", csv_args={
19
+ # 'delimiter': ',',
20
+ # 'quotechar': '"',
21
+ # 'fieldnames': ['Feed_Name', 'Vendor_Name', 'FullDelta', 'Frequency']
22
+ #})
23
+
24
+ #raw_documents = csvloader.load()
25
  raw_documents = loader.load()
26
+ #print(raw_documents)
27
 
28
  # Split text
29
  text_splitter = RecursiveCharacterTextSplitter()
 
32
 
33
  # Load Data to vectorstore
34
  embeddings = OpenAIEmbeddings()
35
+ Vendor_feeds = FAISS.from_documents(documents, embeddings)
36
+ #chatstore = FAISS.from_documents(documents, embeddings)
37
  #vectorstore = FAISS.from_documents(documents, embeddings)
38
 
39
 
40
  # Save vectorstore
41
+ with open("Vendor_feeds.pkl", "wb") as f:
42
+ pickle.dump(Vendor_feeds, f)
43
+
44
+ #with open("chatstore.pkl", "wb") as f:
45
+ # pickle.dump(chatstore, f)
46
  #with open("vectorstore.pkl", "wb") as f:
47
  # pickle.dump(vectorstore, f)
query_data.py CHANGED
@@ -1,6 +1,11 @@
1
  from langchain.prompts.prompt import PromptTemplate
2
- from langchain.llms import OpenAI
3
- from langchain.chains import ChatVectorDBChain
 
 
 
 
 
4
 
5
  _template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
6
  You can assume the question about the most recent response being sent.
@@ -11,7 +16,7 @@ Follow Up Input: {question}
11
  Standalone question:"""
12
  CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)
13
 
14
- template = """You are an AI assistant for answering questions about the most recent chat conversation.
15
  You are given the following extracted parts of a long document and a question. Provide a conversational answer.
16
  If you don't know the answer, just say "Hmm, I'm not sure." Don't try to make up an answer.
17
  If the question is not about the most recent files being sent, politely inform them that you are tuned to only answer questions about the files being outside of contents in this chat.
@@ -20,15 +25,37 @@ Question: {question}
20
  {context}
21
  =========
22
  Answer in Markdown:"""
23
- QA_PROMPT = PromptTemplate(template=template, input_variables=["question", "context"])
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  def get_chain(vectorstore):
27
- llm = OpenAI(temperature=0)
28
- qa_chain = ChatVectorDBChain.from_llm(
29
- llm,
30
- vectorstore,
31
- qa_prompt=QA_PROMPT,
32
- condense_question_prompt=CONDENSE_QUESTION_PROMPT,
33
- )
 
 
 
 
34
  return qa_chain
 
1
  from langchain.prompts.prompt import PromptTemplate
2
+ from langchain.chat_models import ChatOpenAI
3
+ from langchain.chains import ConversationalRetrievalChain
4
+
5
+ #from langchain.chains import ChatVectorDBChain
6
+
7
+ import langchain
8
+ langchain.verbose = False
9
 
10
  _template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
11
  You can assume the question about the most recent response being sent.
 
16
  Standalone question:"""
17
  CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)
18
 
19
+ template_1 = """You are an AI assistant for answering questions about the most recent chat conversation.
20
  You are given the following extracted parts of a long document and a question. Provide a conversational answer.
21
  If you don't know the answer, just say "Hmm, I'm not sure." Don't try to make up an answer.
22
  If the question is not about the most recent files being sent, politely inform them that you are tuned to only answer questions about the files being outside of contents in this chat.
 
25
  {context}
26
  =========
27
  Answer in Markdown:"""
 
28
 
29
+ template_2 = """You are an AI assistant for answering questions about the most recent chat conversation.
30
+ Question: {question}
31
+ =========
32
+ {context}
33
+ =========
34
+ Answer in Markdown:"""
35
+
36
+ qa_template = """
37
+ You are a helpful AI assistant named ICC. The user gives you a file its content is represented by the following pieces of context, use them to answer the question at the end.
38
+ If you don't know the answer, just say you don't know. Do NOT try to make up an answer.
39
+ If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context.
40
+ Use as much detail as possible when responding.
41
+ Question: {question}
42
+ =========
43
+ {context}
44
+ =========
45
+ Answer in Markdown:"""
46
+
47
+ QA_PROMPT = PromptTemplate(template=qa_template, input_variables=["question", "context"])
48
 
49
  def get_chain(vectorstore):
50
+ #llm = ChatOpenAI(temperature=0)
51
+ llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)
52
+ retriever = vectorstore.as_retriever()
53
+ qa_chain = ConversationalRetrievalChain.from_llm(llm=llm,
54
+ retriever=retriever, verbose=False, return_source_documents=True, max_tokens_limit=4097, combine_docs_chain_kwargs={'prompt':QA_PROMPT})
55
+ #qa_chain = ChatVectorDBChain.from_llm(
56
+ # llm,
57
+ # vectorstore,
58
+ # qa_prompt=QA_PROMPT,
59
+ # condense_question_prompt=CONDENSE_QUESTION_PROMPT,
60
+ #)
61
  return qa_chain