diff --git a/README.md b/README.md deleted file mode 100644 index 9d3f4a24..00000000 --- a/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Gen-Ai-Rush-Buildathon - -## Submission Instruction: - 1. Fork this repository - 2. Create a folder with your Team Name - 3. Upload all the code and necessary files in the created folder - 4. Upload a **README.md** file in your folder with the below mentioned informations. - 5. Generate a Pull Request with your Team Name. (Example: submission-XYZ_team) - -## README.md must consist of the following information: - -#### Team Name - -#### Problem Statement - -#### Team Leader Email - - -## A Brief of the Prototype: - This section must include UML Diagrams and prototype description - -## Tech Stack: - List Down all technologies used to Build the prototype - -## Step-by-Step Code Execution Instructions: - This Section must contain a set of instructions required to clone and run the prototype so that it can be tested and deeply analyzed - -## What I Learned: - Write about the biggest learning you had while developing the prototype diff --git a/greenloner/README.md b/greenloner/README.md new file mode 100644 index 00000000..3579c040 --- /dev/null +++ b/greenloner/README.md @@ -0,0 +1,28 @@ +# Gen-Ai-Rush-Buildathon + +#### Team Name - Greenloner +#### Problem Statement - Enterprises face challenges in creating timely and accurate GHG emission reports according to the latest metrics and directives. The current manual procedure takes one to two quarters, which impedes compliance and sustainability initiatives. To automate report generation, cater to enterprises of various sizes, and ensure fast observance of environmental regulations, a solution is required. +#### Team Leader Email - josephthachil.mec@gmail.com + +## A Brief of the Prototype: + + + - Automate the process of creation of GHG emissions using the existing template the firm + uses + - Train a custom LLM with every new iteration of directives and metrics + - Basis the input from the organisation, we would generate the GHG emission report for the + organisation + - Basis the predetermined threshold, we would generate suggestions and roadmaps for the + organisation to reduce their emissions going into the next year + - Generate the list of relevant offset projects to invest in or approximate the amount of credits to buy + +## Tech Stack: + - Python + - OpenAI + - LlamaIndex + +## Step-by-Step Code Execution Instructions: + The prototype is not complete as the exceeded run time has exhausted OpenAI credits + +## What I Learned: + Pivoting to an idea that adds business value is more important than building complex technical systems. diff --git a/greenloner/app.py b/greenloner/app.py new file mode 100644 index 00000000..034b0bcd --- /dev/null +++ b/greenloner/app.py @@ -0,0 +1,81 @@ +import streamlit as st + +def calculate_and_display_score(people_in_household,electric_input, gas_input, oil_input, car_input, flights_4_less_input, flights_4_more_input, recycle_newspaper_selection, recycle_alum_tin_selection): + # Function to calculate and display the carbon footprint score + + def is_checked(option, selected_option): + return option == selected_option + + # Check selection made for recycling newspaper before calculating and displaying score + if (not is_checked(recycle_newspaper_selection, "Yes") and not is_checked(recycle_newspaper_selection, "No")) or \ + (not is_checked(recycle_alum_tin_selection, "Yes") and not is_checked(recycle_alum_tin_selection, "No")): + st.error("Please select whether you recycle newspapers and aluminum/tin.") + else: + # Convert radio button selections to boolean values + recycle_newspaper_selection_yes = is_checked(recycle_newspaper_selection, "Yes") + recycle_alum_tin_selection_yes = is_checked(recycle_alum_tin_selection, "Yes") + + # Set variables for calculating each component score + newspaper_score = 0 if recycle_newspaper_selection_yes else 184 + alum_tin_score = 0 if recycle_alum_tin_selection_yes else 166 + + electric_score = 0 if electric_input == 0 or electric_input == "undefined" else electric_input * 105 + gas_score = 0 if gas_input == 0 or gas_input == "undefined" else gas_input * 105 + oil_score = 0 if oil_input == 0 or oil_input == "undefined" else oil_input * 113 + car_score = 0 if car_input == 0 or car_input == "undefined" else car_input * 0.79 + flights_4_less_score = 0 if flights_4_less_input == 0 or flights_4_less_input == "undefined" else flights_4_less_input * 1100 + flights_4_more_score = 0 if flights_4_more_input == 0 or flights_4_more_input == "undefined" else flights_4_more_input * 4400 + + # Calculate scores for each category + energy_score = electric_score + gas_score + oil_score + travel_score = car_score + flights_4_less_score + flights_4_more_score + waste_score = newspaper_score + alum_tin_score + + # Calculate total score and round to the nearest whole integer + total_score = round(energy_score + travel_score + waste_score) + formatted_score = "{:,}".format(total_score/people_in_household) + + # Display results + st.markdown(f"## Your Carbon Footprint Score: {formatted_score}") + + +# Main function for the Streamlit app +def main(): + # Hide results template and error alerts on initial page load + st.markdown("# Carbon Footprint Calculator") + st.markdown("### Enter the following data to calculate your carbon footprint:") + + # Get input values using Streamlit widgets + people_in_household = st.number.input("Number of people in household", value = 0) + electric_input = st.number_input("Electricity consumption (kWh)", value=0.0) + gas_input = st.number_input("Gas consumption (therms)", value=0.0) + oil_input = st.number_input("Oil consumption (gallons)", value=0.0) + car_input = st.number_input("Car travel (miles)", value=0.0) + flights_4_less_input = st.number_input("Flights taken 4 hours or less", value=0.0) + flights_4_more_input = st.number_input("Flights taken 4 hours or more", value=0.0) + + recycle_newspaper_selection = st.radio("Do you recycle newspapers?", ("Yes", "No")) + recycle_alum_tin_selection = st.radio("Do you recycle aluminum and tin?", ("Yes", "No")) + + # Add click event listener for the Calculate button + if st.button("Calculate"): + # Convert radio button selections to boolean values + recycle_newspaper_selection_yes = recycle_newspaper_selection == "Yes" + recycle_newspaper_selection_no = recycle_newspaper_selection == "No" + recycle_alum_tin_selection_yes = recycle_alum_tin_selection == "Yes" + recycle_alum_tin_selection_no = recycle_alum_tin_selection == "No" + + # Check selection made for recycling newspaper before calculating and displaying score + if (not recycle_newspaper_selection_yes and not recycle_newspaper_selection_no) or \ + (not recycle_alum_tin_selection_yes and not recycle_alum_tin_selection_no): + if not recycle_newspaper_selection_yes and not recycle_newspaper_selection_no: + st.error("Please select whether you recycle newspapers.") + if not recycle_alum_tin_selection_yes and not recycle_alum_tin_selection_no: + st.error("Please select whether you recycle aluminum and tin.") + else: + # Calculate and display the carbon footprint score + calculate_and_display_score(people_in_household,electric_input, gas_input, oil_input, car_input, flights_4_less_input, flights_4_more_input, recycle_newspaper_selection, recycle_alum_tin_selection) + +# Entry point of the Streamlit app +if __name__ == "__main__": + main() diff --git a/greenloner/app1.py b/greenloner/app1.py new file mode 100644 index 00000000..2a1aa9c1 --- /dev/null +++ b/greenloner/app1.py @@ -0,0 +1,77 @@ +import streamlit as st +import urllib +import base64 +import os +from llama_index import VectorStoreIndex, SimpleDirectoryReader, ListIndex +from dotenv import load_dotenv + +#load_dotenv() + +import openai +os.environ['OPENAI_API_KEY'] = "" + +def create_data_directory(): + if not os.path.exists("data"): + os.makedirs("data") + +#function to save a file +def save_uploadedfile(uploadedfile): + with open(os.path.join("data",uploadedfile.name),"wb") as f: + f.write(uploadedfile.getbuffer()) + return st.success("Saved File:{} to directory".format(uploadedfile.name)) + +@st.cache_data +#function to display the PDF of a given file +def displayPDF(file): + # Opening file from file path + with open(file, "rb") as f: + base64_pdf = base64.b64encode(f.read()).decode('utf-8') + + # Embedding PDF in HTML + pdf_display = F'' + + # Displaying File + st.markdown(pdf_display, unsafe_allow_html=True) + +#semantic search +def semantic_search(query): + documents = SimpleDirectoryReader('data').load_data() + index = ListIndex.from_documents(documents) + query_engine = index.as_query_engine() + response = query_engine.query(query) + return response +#summarization +def summarize(file): + documents = SimpleDirectoryReader('data').load_data() + index = ListIndex.from_documents(documents) + query_engine = index.as_query_engine() + response = query_engine.query("Is the report compliant with all the GHG emission metrics?") + return response + +#streamlit application +st. set_page_config(layout='wide') + +st.title('Semantic Search Application') + +uploaded_pdf = st.file_uploader("Upload your PDF", type=['pdf']) + +if uploaded_pdf is not None: + col1,col2,col3 = st.columns([2,1,1]) + with col1: + input_file = save_uploadedfile(uploaded_pdf) + pdf_file = "data/"+uploaded_pdf.name + pdf_view = displayPDF(pdf_file) + with col2: + st.success("Search Area") + query_search = st.text_area("Search your query") + if st.checkbox("search"): + st.info("Your query: "+query_search) + result = semantic_search(query_search) + st.write(result.response) + print(result) + with col3: + st.success("Automated Summarization") + summary_result = summarize(pdf_file) + st.write(summary_result.response) + print(summary_result) + \ No newline at end of file diff --git a/greenloner/app2.py b/greenloner/app2.py new file mode 100644 index 00000000..90a92b54 --- /dev/null +++ b/greenloner/app2.py @@ -0,0 +1,79 @@ +import streamlit as st +import urllib +import base64 +import os +from llama_index import VectorStoreIndex, SimpleDirectoryReader, GPTListIndex +from dotenv import load_dotenv +import openai + +load_dotenv() + +#os.environ['OPENAI_API_KEY'] = +openai.api_key = "" + +#function to save a file +def save_uploadedfile(uploadedfile): + with open(os.path.join("data",uploadedfile.name),"wb") as f: + f.write(uploadedfile.getbuffer()) + return st.success("Saved File:{} to directory".format(uploadedfile.name)) + +@st.cache_data +#function to display the PDF of a given file +def displayPDF(file): + # Opening file from file path + with open(file, "rb") as f: + base64_pdf = base64.b64encode(f.read()).decode('utf-8') + + # Embedding PDF in HTML + pdf_display = F'' + + # Displaying File + st.markdown(pdf_display, unsafe_allow_html=True) + +#semantic search +def semantic_search(query): + print(query) + documents = SimpleDirectoryReader('data').load_data() + #print(documents) + index = VectorStoreIndex.from_documents(documents) + print("testing") + query_engine = index.as_query_engine() + response = query_engine.query(query) + print(response) + return response + +#summarization +def summarize(file): + documents = SimpleDirectoryReader('data').load_data() + index = GPTListIndex.from_documents(documents) + #query_engine = index.as_query_engine() + response = index.query(file,response_mode="tree_summarize") + return response + +#streamlit application +st. set_page_config(layout='wide') + +st.title('Carbon Policy Summarizer') + +uploaded_pdf = st.file_uploader("Upload your PDF", type=['pdf']) + +if uploaded_pdf is not None: + col1, col2, col3 = st.columns([2,1,1]) + with col1: + input_file = save_uploadedfile(uploaded_pdf) + pdf_file = "data/"+uploaded_pdf.name + pdf_view = displayPDF(pdf_file) + with col2: + st.success("Search Area") + query_search = st.text_area("Search your query") + if st.checkbox("search"): + st.info("Your query: "+query_search) + result = semantic_search(query_search) + st.write(result) + with col3: + st.success("Summarization Area") + query_search1 = st.text_area("How do you want to summarize") + if st.checkbox("summarize"): + st.info("Your Summarize prompt: "+query_search1) + summary_result = summarize(query_search1) + st.write(summary_result) \ No newline at end of file diff --git a/greenloner/data/ghg-protocol-revised.pdf b/greenloner/data/ghg-protocol-revised.pdf new file mode 100644 index 00000000..3eb2cbbe Binary files /dev/null and b/greenloner/data/ghg-protocol-revised.pdf differ diff --git a/greenloner/files/2021-Metrics_Targets_Guidance-1.pdf b/greenloner/files/2021-Metrics_Targets_Guidance-1.pdf new file mode 100644 index 00000000..4caa0a91 Binary files /dev/null and b/greenloner/files/2021-Metrics_Targets_Guidance-1.pdf differ diff --git a/greenloner/files/2021-TCFD-Implementing_Guidance.pdf b/greenloner/files/2021-TCFD-Implementing_Guidance.pdf new file mode 100644 index 00000000..7ca11725 Binary files /dev/null and b/greenloner/files/2021-TCFD-Implementing_Guidance.pdf differ diff --git a/greenloner/files/Consolidated Set of the GRI Standards.pdf b/greenloner/files/Consolidated Set of the GRI Standards.pdf new file mode 100644 index 00000000..b9d0592a Binary files /dev/null and b/greenloner/files/Consolidated Set of the GRI Standards.pdf differ diff --git a/greenloner/files/FINAL-2017-TCFD-Report.pdf b/greenloner/files/FINAL-2017-TCFD-Report.pdf new file mode 100644 index 00000000..d0948134 Binary files /dev/null and b/greenloner/files/FINAL-2017-TCFD-Report.pdf differ diff --git a/greenloner/files/GHG-Protocol-Reporting-Template.docx b/greenloner/files/GHG-Protocol-Reporting-Template.docx new file mode 100644 index 00000000..9500f761 Binary files /dev/null and b/greenloner/files/GHG-Protocol-Reporting-Template.docx differ diff --git a/greenloner/files/PB 53 - Household Carbon Footprint of India_2nd draft.pdf b/greenloner/files/PB 53 - Household Carbon Footprint of India_2nd draft.pdf new file mode 100644 index 00000000..202609bc Binary files /dev/null and b/greenloner/files/PB 53 - Household Carbon Footprint of India_2nd draft.pdf differ diff --git a/greenloner/files/ReNew Power SR 2021-22 - final file web-ready - 26.10.2022 copy.pdf b/greenloner/files/ReNew Power SR 2021-22 - final file web-ready - 26.10.2022 copy.pdf new file mode 100644 index 00000000..14a50f71 Binary files /dev/null and b/greenloner/files/ReNew Power SR 2021-22 - final file web-ready - 26.10.2022 copy.pdf differ diff --git a/greenloner/files/ReNew Power SR 2021-22 - final file web-ready - 26.10.2022.pdf b/greenloner/files/ReNew Power SR 2021-22 - final file web-ready - 26.10.2022.pdf new file mode 100644 index 00000000..14a50f71 Binary files /dev/null and b/greenloner/files/ReNew Power SR 2021-22 - final file web-ready - 26.10.2022.pdf differ diff --git a/greenloner/files/self-assessment-template-ghg-reporting-for-businesses.docx b/greenloner/files/self-assessment-template-ghg-reporting-for-businesses.docx new file mode 100644 index 00000000..a3c2e002 Binary files /dev/null and b/greenloner/files/self-assessment-template-ghg-reporting-for-businesses.docx differ diff --git a/greenloner/uml-diagram.png b/greenloner/uml-diagram.png new file mode 100644 index 00000000..885a362e Binary files /dev/null and b/greenloner/uml-diagram.png differ