Rajagopal commited on
Commit
4fe6e77
0 Parent(s):

Duplicate from Rajagopal/try4245

Browse files
Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +13 -0
  3. app.py +57 -0
  4. requirements.txt +7 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Contract Summarization
3
+ emoji: 🏆
4
+ colorFrom: yellow
5
+ colorTo: gray
6
+ sdk: streamlit
7
+ sdk_version: 1.21.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: Rajagopal/try4245
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain import OpenAI, PromptTemplate, LLMChain
3
+ from langchain.text_splitter import CharacterTextSplitter
4
+ from langchain.chains.mapreduce import MapReduceChain
5
+ from langchain.prompts import PromptTemplate
6
+ from langchain.chat_models import AzureChatOpenAI
7
+ from langchain.chains.summarize import load_summarize_chain
8
+ from langchain.chains import AnalyzeDocumentChain
9
+ from PyPDF2 import PdfReader
10
+ from langchain.document_loaders import TextLoader
11
+ from langchain.indexes import VectorstoreIndexCreator
12
+ from langchain.document_loaders import PyPDFLoader
13
+
14
+
15
+
16
+ import os
17
+ os.environ["OPENAI_API_TYPE"] = "azure"
18
+ os.environ["OPENAI_API_VERSION"] = "2023-05-15"
19
+ os.environ["OPENAI_API_BASE"] = "https://cog-mnjbf5r4o6b3e.openai.azure.com/"
20
+ os.environ["OPENAI_API_KEY"] = "957f7d98b47a467a98a786f7ca903112"
21
+
22
+ llm = AzureChatOpenAI(
23
+ deployment_name="gpt-4",
24
+ openai_api_version="2023-03-15-preview")
25
+
26
+
27
+
28
+ st.title("Contract Management System")
29
+
30
+ # description text
31
+ st.write("""Hello! I'm an Al chatbot specifically created to assist vou with any procurement-related questions you may have. My range of capabilities includes providing information on contract expiry dates payment terms, and other relevant details.
32
+
33
+ Feel free to ask me anything you need help with!
34
+ To get started, just provide me with the contract number and let me know what specitic details you're interested in. Additionally, tee tree to ask me any general questions you may have regardinc procurement. I'm here to assist vou in any way can 😊""")
35
+
36
+ # pdf file upload
37
+ pdf_file = st.file_uploader("Upload file", type=["pdf"])
38
+
39
+
40
+ def extract_text_from_pdf():
41
+ reader = PdfReader(pdf_file)
42
+ # get all pages text
43
+ text = [reader.pages[i].extract_text() for i in range(len(reader.pages))]
44
+ # join all pages text
45
+ text = " ".join(text)
46
+ return text
47
+
48
+
49
+
50
+ if st.button("Summerize Contract"):
51
+ with st.spinner("Extracting Text..."):
52
+ summary_chain = load_summarize_chain(llm, chain_type="map_reduce")
53
+ summarize_document_chain = AnalyzeDocumentChain(combine_docs_chain=summary_chain, verbose=True)
54
+ text = extract_text_from_pdf()
55
+ with st.spinner("Summarizing..."):
56
+ result = summarize_document_chain.run(text)
57
+ st.write(result)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ openai
2
+ langchain
3
+ streamlit
4
+ PyPDF2
5
+ tiktoken
6
+ pypdf
7
+ chromadb