Update app.py
Browse files
app.py
CHANGED
|
@@ -29,64 +29,7 @@ openai.api_key = os.environ["OPENAI_API_KEY"]
|
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
-
st.title("Wipro ")
|
| 33 |
-
|
| 34 |
-
# description text
|
| 35 |
-
st.write("Step 1: Summary of your selected section of CSRD... Sections in this are enviormental topic1, enviornamtal topic2 ")
|
| 36 |
-
st.write("Step 2: Ask your specfici questions regarding a CSRD disclosure requirments")
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# pdf file upload
|
| 40 |
-
pdf_file = st.file_uploader("Upload file", type=["pdf"])
|
| 41 |
-
|
| 42 |
-
numberofpages = 100
|
| 43 |
-
|
| 44 |
-
if st.button("How many pages? "):
|
| 45 |
-
reader = PdfReader(pdf_file)
|
| 46 |
-
numberofpages = len(reader.pages)
|
| 47 |
-
st.write("length is ", numberofpages)
|
| 48 |
-
|
| 49 |
-
if st.button("table of contents? "):
|
| 50 |
-
reader = PdfReader(pdf_file)
|
| 51 |
-
page = reader.pages[2].extract_text()
|
| 52 |
-
st.write(page)
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
startpage = st.slider('Which section to look at', 0, numberofpages, 1)
|
| 58 |
-
st.write("starting section page", startpage)
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
pagecount = st.slider('How many pages', 1, 5, 1)
|
| 62 |
-
st.write("pages to read", pagecount)
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
def extract_text_from_pdf():
|
| 66 |
-
reader = PdfReader(pdf_file)
|
| 67 |
-
# get all pages text
|
| 68 |
-
text = [reader.pages[i].extract_text() for i in range(startpage, startpage + pagecount )]
|
| 69 |
-
# join all pages text
|
| 70 |
-
text = " ".join(text)
|
| 71 |
-
return text
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
def extract_text_from_pdf2():
|
| 75 |
-
reader = PdfReader(pdf_file)
|
| 76 |
-
# get all pages text
|
| 77 |
-
text = [reader.pages[i].extract_text() for i in range(len(reader.pages))]
|
| 78 |
-
# join all pages text
|
| 79 |
-
text = " ".join(text)
|
| 80 |
-
return text
|
| 81 |
-
|
| 82 |
-
if st.button("Summerize "):
|
| 83 |
-
with st.spinner("Extracting Text..."):
|
| 84 |
-
summary_chain = load_summarize_chain(llm, chain_type="map_reduce")
|
| 85 |
-
summarize_document_chain = AnalyzeDocumentChain(combine_docs_chain=summary_chain, verbose=True)
|
| 86 |
-
text = extract_text_from_pdf()
|
| 87 |
-
with st.spinner("Summarizing..."):
|
| 88 |
-
result = summarize_document_chain.run(text)
|
| 89 |
-
st.write(result)
|
| 90 |
|
| 91 |
|
| 92 |
|
|
@@ -104,7 +47,7 @@ if st.button("Ask Questions "):
|
|
| 104 |
|
| 105 |
response = openai.ChatCompletion.create(
|
| 106 |
engine="gpt-35-turbo",
|
| 107 |
-
messages = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":
|
| 108 |
temperature=0,
|
| 109 |
max_tokens=800,
|
| 110 |
top_p=1,
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
+
st.title("Wipro demo with azure cognitive ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
|
|
|
|
| 47 |
|
| 48 |
response = openai.ChatCompletion.create(
|
| 49 |
engine="gpt-35-turbo",
|
| 50 |
+
messages = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":yourquestion}],
|
| 51 |
temperature=0,
|
| 52 |
max_tokens=800,
|
| 53 |
top_p=1,
|