Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,9 @@ from hyperrag import build_graph
|
|
| 9 |
from analysis import answer
|
| 10 |
from discourse_graph import add_claim, detect_greenwashing
|
| 11 |
|
|
|
|
| 12 |
|
| 13 |
-
st.
|
| 14 |
-
page_title="ESG HyperRAG Platform",
|
| 15 |
-
layout="wide"
|
| 16 |
-
)
|
| 17 |
-
|
| 18 |
-
st.title("π ESG HyperRAG Intelligence Platform")
|
| 19 |
|
| 20 |
st.sidebar.header("Upload ESG Report")
|
| 21 |
|
|
@@ -25,87 +21,66 @@ company = st.sidebar.text_input("Company")
|
|
| 25 |
|
| 26 |
sector = st.sidebar.text_input("Sector")
|
| 27 |
|
| 28 |
-
|
| 29 |
-
if st.sidebar.button("Analyze Report"):
|
| 30 |
|
| 31 |
if file and company and sector:
|
| 32 |
|
| 33 |
text = extract_text(file)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
scope3 = extract_scope(text,3)
|
| 40 |
|
| 41 |
revenue = extract_revenue(text)
|
| 42 |
|
| 43 |
-
intensity = carbon_intensity(
|
| 44 |
|
| 45 |
index_doc(text,{
|
| 46 |
"company":company,
|
| 47 |
"sector":sector,
|
| 48 |
-
"scope1":
|
| 49 |
-
"scope2":
|
| 50 |
-
"scope3":
|
| 51 |
-
"
|
| 52 |
-
"carbon_intensity":intensity
|
| 53 |
})
|
| 54 |
|
| 55 |
build_graph([text])
|
| 56 |
|
| 57 |
-
add_claim(company,"low emissions",f"Scope1 {
|
| 58 |
|
| 59 |
-
st.success("Report processed
|
| 60 |
|
| 61 |
df = pd.DataFrame({
|
| 62 |
-
|
| 63 |
"Scope":["Scope1","Scope2","Scope3"],
|
| 64 |
-
|
| 65 |
-
"Value":[scope1,scope2,scope3]
|
| 66 |
-
|
| 67 |
})
|
| 68 |
|
| 69 |
-
fig = px.bar(
|
| 70 |
-
|
| 71 |
-
df,
|
| 72 |
-
|
| 73 |
-
x="Scope",
|
| 74 |
-
|
| 75 |
-
y="Value",
|
| 76 |
-
|
| 77 |
-
color="Scope",
|
| 78 |
-
|
| 79 |
-
title="Emission Breakdown"
|
| 80 |
-
|
| 81 |
-
)
|
| 82 |
|
| 83 |
st.plotly_chart(fig,use_container_width=True)
|
| 84 |
|
| 85 |
st.metric("Carbon Intensity", intensity)
|
| 86 |
|
| 87 |
|
| 88 |
-
st.header("π HyperRAG
|
| 89 |
-
|
| 90 |
-
query = st.text_input("Ask ESG question")
|
| 91 |
|
| 92 |
-
|
| 93 |
|
| 94 |
-
|
| 95 |
|
| 96 |
-
st.text(
|
| 97 |
|
| 98 |
|
| 99 |
st.header("π¨ Greenwashing Detection")
|
| 100 |
|
| 101 |
-
if st.button("Check
|
| 102 |
|
| 103 |
issues = detect_greenwashing()
|
| 104 |
|
| 105 |
if issues:
|
| 106 |
|
| 107 |
-
st.error(f"Potential contradictions
|
| 108 |
|
| 109 |
else:
|
| 110 |
|
| 111 |
-
st.success("No
|
|
|
|
| 9 |
from analysis import answer
|
| 10 |
from discourse_graph import add_claim, detect_greenwashing
|
| 11 |
|
| 12 |
+
st.set_page_config(layout="wide")
|
| 13 |
|
| 14 |
+
st.title("π± ESG HyperRAG Analyzer")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
st.sidebar.header("Upload ESG Report")
|
| 17 |
|
|
|
|
| 21 |
|
| 22 |
sector = st.sidebar.text_input("Sector")
|
| 23 |
|
| 24 |
+
if st.sidebar.button("Analyze"):
|
|
|
|
| 25 |
|
| 26 |
if file and company and sector:
|
| 27 |
|
| 28 |
text = extract_text(file)
|
| 29 |
|
| 30 |
+
s1 = extract_scope(text,1)
|
| 31 |
+
s2 = extract_scope(text,2)
|
| 32 |
+
s3 = extract_scope(text,3)
|
|
|
|
|
|
|
| 33 |
|
| 34 |
revenue = extract_revenue(text)
|
| 35 |
|
| 36 |
+
intensity = carbon_intensity(s1,revenue)
|
| 37 |
|
| 38 |
index_doc(text,{
|
| 39 |
"company":company,
|
| 40 |
"sector":sector,
|
| 41 |
+
"scope1":s1,
|
| 42 |
+
"scope2":s2,
|
| 43 |
+
"scope3":s3,
|
| 44 |
+
"intensity":intensity
|
|
|
|
| 45 |
})
|
| 46 |
|
| 47 |
build_graph([text])
|
| 48 |
|
| 49 |
+
add_claim(company,"low emissions",f"Scope1 {s1}")
|
| 50 |
|
| 51 |
+
st.success("Report processed")
|
| 52 |
|
| 53 |
df = pd.DataFrame({
|
|
|
|
| 54 |
"Scope":["Scope1","Scope2","Scope3"],
|
| 55 |
+
"Value":[s1,s2,s3]
|
|
|
|
|
|
|
| 56 |
})
|
| 57 |
|
| 58 |
+
fig = px.bar(df,x="Scope",y="Value",color="Scope")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
st.plotly_chart(fig,use_container_width=True)
|
| 61 |
|
| 62 |
st.metric("Carbon Intensity", intensity)
|
| 63 |
|
| 64 |
|
| 65 |
+
st.header("π HyperRAG Query")
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
q = st.text_input("Ask ESG question")
|
| 68 |
|
| 69 |
+
if st.button("Search"):
|
| 70 |
|
| 71 |
+
st.text(answer(q))
|
| 72 |
|
| 73 |
|
| 74 |
st.header("π¨ Greenwashing Detection")
|
| 75 |
|
| 76 |
+
if st.button("Check"):
|
| 77 |
|
| 78 |
issues = detect_greenwashing()
|
| 79 |
|
| 80 |
if issues:
|
| 81 |
|
| 82 |
+
st.error(f"Potential contradictions: {issues}")
|
| 83 |
|
| 84 |
else:
|
| 85 |
|
| 86 |
+
st.success("No greenwashing detected")
|