Prat0 commited on
Commit
7d59a7c
·
verified ·
1 Parent(s): b5a35a2

Update pages/Report_Writer.py

Browse files
Files changed (1) hide show
  1. pages/Report_Writer.py +32 -28
pages/Report_Writer.py CHANGED
@@ -9,6 +9,8 @@ from llama_index.core import DocumentSummaryIndex
9
  import google.generativeai as genai
10
  import os
11
  import PyPDF2
 
 
12
 
13
  # Set up Google API key
14
 
@@ -111,38 +113,40 @@ def main():
111
  st.title("AI Report Writer")
112
  st.write("Upload your document and our AI will generate a comprehensive report based on its contents!")
113
 
 
 
114
  # File uploader
115
- uploaded_file = st.file_uploader("Choose a file (PDF or TXT)", type=["txt", "pdf"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
- # Report format input
118
- report_format = st.text_area("Enter the desired report format (optional)", height=150,
119
- help="Leave blank to use a default template")
 
120
 
121
- # Additional information input
122
- additional_info = st.text_area("Enter any additional information or context for the report", height=100)
123
-
124
- if uploaded_file is not None:
125
- # Read file contents
126
- if uploaded_file.type == "application/pdf":
127
- pdf_reader = PyPDF2.PdfReader(uploaded_file)
128
- document_text = ""
129
- for page in pdf_reader.pages:
130
- document_text += page.extract_text()
131
  else:
132
- document_text = uploaded_file.getvalue().decode("utf-8")
133
-
134
- if st.button("Generate Report"):
135
- st.write("Analyzing document and generating report...")
136
-
137
- # Load data and generate report
138
- doc_list = document_text.split(".")
139
- index = load_data(document_text)
140
- report = generate_report(index, report_format, additional_info)
141
-
142
- st.write("## Generated Report")
143
- st.write(report)
144
- else:
145
- st.warning("Please upload a file to generate a report.")
146
 
147
  if __name__ == "__main__":
148
  main()
 
9
  import google.generativeai as genai
10
  import os
11
  import PyPDF2
12
+ import streamlit_analytics2 as streamlit_analytics
13
+
14
 
15
  # Set up Google API key
16
 
 
113
  st.title("AI Report Writer")
114
  st.write("Upload your document and our AI will generate a comprehensive report based on its contents!")
115
 
116
+ with streamlit_analytics.track():
117
+
118
  # File uploader
119
+ uploaded_file = st.file_uploader("Choose a file (PDF or TXT)", type=["txt", "pdf"])
120
+
121
+ # Report format input
122
+ report_format = st.text_area("Enter the desired report format (optional)", height=150,
123
+ help="Leave blank to use a default template")
124
+
125
+ # Additional information input
126
+ additional_info = st.text_area("Enter any additional information or context for the report", height=100)
127
+
128
+ if uploaded_file is not None:
129
+ # Read file contents
130
+ if uploaded_file.type == "application/pdf":
131
+ pdf_reader = PyPDF2.PdfReader(uploaded_file)
132
+ document_text = ""
133
+ for page in pdf_reader.pages:
134
+ document_text += page.extract_text()
135
+ else:
136
+ document_text = uploaded_file.getvalue().decode("utf-8")
137
+
138
+ if st.button("Generate Report"):
139
+ st.write("Analyzing document and generating report...")
140
 
141
+ # Load data and generate report
142
+ doc_list = document_text.split(".")
143
+ index = load_data(document_text)
144
+ report = generate_report(index, report_format, additional_info)
145
 
146
+ st.write("## Generated Report")
147
+ st.write(report)
 
 
 
 
 
 
 
 
148
  else:
149
+ st.warning("Please upload a file to generate a report.")
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
  if __name__ == "__main__":
152
  main()