Update app.py
Browse files
app.py
CHANGED
|
@@ -1,94 +1,24 @@
|
|
| 1 |
|
| 2 |
-
import PyPDF2
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
-
st.title(
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
reader = PyPDF2.PdfReader(uploaded_file)
|
| 12 |
-
num_pages = len(reader.pages)
|
| 13 |
-
|
| 14 |
-
if start_page < 0 or start_page >= num_pages:
|
| 15 |
-
start_page = 0
|
| 16 |
-
if end_page < start_page or end_page >= num_pages:
|
| 17 |
-
end_page = num_pages - 1
|
| 18 |
-
|
| 19 |
-
text = ''
|
| 20 |
-
for page_num in range(start_page, end_page + 1):
|
| 21 |
-
page = reader.pages[page_num]
|
| 22 |
-
text += page.extract_text()
|
| 23 |
-
|
| 24 |
-
return text
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
# Rest of your code remains the same
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
st.text("Upload a project submission")
|
| 31 |
-
pdf_path = st.file_uploader("Choose a file")
|
| 32 |
-
start_page = 0
|
| 33 |
-
end_page = 117
|
| 34 |
-
submission_text = extract_text_from_pdf(pdf_path, start_page, end_page)
|
| 35 |
-
#print(submission_text)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
pdf_path = 'VCS-Standard.pdf'
|
| 42 |
-
start_page = 0 # Start extracting from the first page (0-based index)
|
| 43 |
-
end_page = 93 # Extract up to the third page (0-based index)
|
| 44 |
-
vcs_text = extract_text_from_pdf(pdf_path, start_page, end_page)
|
| 45 |
-
print(vcs_text)
|
| 46 |
-
|
| 47 |
-
pdf_path = 'VCS-Methodology-Requirements.pdf'
|
| 48 |
-
start_page = 0 # Start extracting from the first page (0-based index)
|
| 49 |
-
end_page = 89 # Extract up to the third page (0-based index)
|
| 50 |
-
methodology_text = extract_text_from_pdf(pdf_path, start_page, end_page)
|
| 51 |
-
print(methodology_text)
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
#
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
import google.generativeai as genai
|
| 68 |
-
|
| 69 |
-
from IPython.display import display
|
| 70 |
-
from IPython.display import Markdown
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
def to_markdown(text):
|
| 74 |
-
text = text.replace('•', ' *')
|
| 75 |
-
return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
GOOGLE_API_KEY="AIzaSyCDFpWY_8xI9ESgBLVzEtz1EV1kzaPB62I"
|
| 80 |
-
genai.configure(api_key=GOOGLE_API_KEY)
|
| 81 |
-
|
| 82 |
-
for m in genai.list_models():
|
| 83 |
-
if 'generateContent' in m.supported_generation_methods:
|
| 84 |
-
print(m.name)
|
| 85 |
-
|
| 86 |
-
#For text-only prompts, use a Gemini 1.5 model or the Gemini 1.0 Pro model:
|
| 87 |
-
model = genai.GenerativeModel('gemini-1.5-flash-latest')
|
| 88 |
-
|
| 89 |
-
# Commented out IPython magic to ensure Python compatibility.
|
| 90 |
-
if st.button("Evaluate", 2):
|
| 91 |
-
# %%time
|
| 92 |
-
response = model.generate_content("You are a project verifier officer at Verra, the leading registry for projects used to generate carbon credits. Your job is to look into project submissions from project developers who create an implement nature-based solutions in order to generate carbon credits. You go through the content of the project submissions to investigate whether the submission fits into the vcs standards, methodology requirements, and touches everything on the project description template. A verifier has to compare the submission to these 3 main criteria. As a verifier, I want you to evaluate the project submission below based on the resources listed below. The output should be in the format of summary of the project submission, the level of adherence to the standards, what needs to be fixed, and notes for improvement for project developers. The output needs to have project-specific feedback. You can bolster your feedback with quotes from the submission or referencing numbers mentioned in the submission. Here is the project submission:" + submission_text + "Here is the vcs standards:" + vcs_text + "Here is the methodology requirement:" + methodology_text + "Here is the project description template:" + template_text)
|
| 93 |
-
to_markdown(response.text)
|
| 94 |
-
st.write(response.text)
|
|
|
|
| 1 |
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
+
st.sidebar.title("Navigation")
|
| 5 |
+
page = st.sidebar.radio("Go to", ["Home", "Project Developer", "Verification Body"])
|
| 6 |
|
| 7 |
+
if page == "Home":
|
| 8 |
+
st.title("Hi! Welcome to the NBS Project Submission Platform")
|
| 9 |
+
st.write("Please use the sidebar to navigate between options.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Project Developer Page
|
| 12 |
+
elif page == "Project Developer":
|
| 13 |
+
st.title("Project Developer Portal")
|
| 14 |
+
st.write("You can submit your project for evaluation here.")
|
| 15 |
+
|
| 16 |
+
# This will import and run the code from project_developer.py
|
| 17 |
+
# Importing streamlit_app functions here or you can move all the code into this block
|
| 18 |
+
import developer
|
| 19 |
+
developer.run()
|
| 20 |
+
|
| 21 |
+
# Verification Body Page (you can implement this later)
|
| 22 |
+
elif page == "Verification Body":
|
| 23 |
+
st.title("Verification Body Portal")
|
| 24 |
+
st.write("This section is for verification officers.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|