ESGToolKit / app.py
GirishaBuilds01's picture
Update app.py
3ebd5b5 verified
import streamlit as st
import pandas as pd
import plotly.express as px
from pdf_parser import extract_text
from esg_metrics import extract_scope, extract_revenue, carbon_intensity
from vector_store import index_doc
from hyperrag import build_graph
from analysis import answer
from discourse_graph import add_claim, detect_greenwashing
st.set_page_config(layout="wide")
st.title("🌱 ESG HyperRAG Analyzer")
st.sidebar.header("Upload ESG Report")
file = st.sidebar.file_uploader("Upload ESG PDF", type=["pdf"])
company = st.sidebar.text_input("Company")
sector = st.sidebar.text_input("Sector")
if st.sidebar.button("Analyze"):
if file and company and sector:
text = extract_text(file)
s1 = extract_scope(text,1)
s2 = extract_scope(text,2)
s3 = extract_scope(text,3)
revenue = extract_revenue(text)
intensity = carbon_intensity(s1,revenue)
index_doc(text,{
"company":company,
"sector":sector,
"scope1":s1,
"scope2":s2,
"scope3":s3,
"intensity":intensity
})
build_graph([text])
add_claim(company,"low emissions",f"Scope1 {s1}")
st.success("Report processed")
df = pd.DataFrame({
"Scope":["Scope1","Scope2","Scope3"],
"Value":[s1,s2,s3]
})
fig = px.bar(df,x="Scope",y="Value",color="Scope")
st.plotly_chart(fig,use_container_width=True)
st.metric("Carbon Intensity", intensity)
st.header("πŸ”Ž HyperRAG Query")
q = st.text_input("Ask ESG question")
if st.button("Search"):
st.text(answer(q))
st.header("🚨 Greenwashing Detection")
if st.button("Check"):
issues = detect_greenwashing()
if issues:
st.error(f"Potential contradictions: {issues}")
else:
st.success("No greenwashing detected")