carolinejean-pierre commited on
Commit
017c2ee
·
1 Parent(s): 0d3291a

Add how to use information

Browse files

Update calculator_mode
add navigation button and two pages to display equivalents per impact

Files changed (1) hide show
  1. src/calculator.py +16 -8
src/calculator.py CHANGED
@@ -1,15 +1,17 @@
1
  import streamlit as st
2
 
3
  from ecologits.tracers.utils import llm_impacts
4
- from src.impacts import get_impacts, display_impacts, display_equivalent
5
  from src.utils import format_impacts
6
- from src.content import WARNING_CLOSED_SOURCE, WARNING_MULTI_MODAL, WARNING_BOTH
7
  from src.models import load_models
8
 
9
  from src.constants import PROMPTS
10
 
11
  def calculator_mode():
12
 
 
 
13
  with st.container(border=True):
14
 
15
  df = load_models(filter_main=True)
@@ -59,14 +61,20 @@ def calculator_mode():
59
  with st.container(border=True):
60
 
61
  st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
62
- st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
63
- display_impacts(impacts)
64
 
65
- with st.container(border=True):
66
-
67
- st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
68
  st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
69
- display_equivalent(impacts)
 
 
 
 
 
 
 
70
 
71
  except Exception as e:
72
  st.error('Could not find the model in the repository. Please try another model.')
 
1
  import streamlit as st
2
 
3
  from ecologits.tracers.utils import llm_impacts
4
+ from src.impacts import get_impacts, display_impacts, display_equivalent_ghg, display_equivalent_energy
5
  from src.utils import format_impacts
6
+ from src.content import WARNING_CLOSED_SOURCE, WARNING_MULTI_MODAL, WARNING_BOTH, HOW_TO_TEXT
7
  from src.models import load_models
8
 
9
  from src.constants import PROMPTS
10
 
11
  def calculator_mode():
12
 
13
+ st.expander("How to Use this calculator", expanded = False).markdown(HOW_TO_TEXT)
14
+
15
  with st.container(border=True):
16
 
17
  df = load_models(filter_main=True)
 
61
  with st.container(border=True):
62
 
63
  st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
64
+ #st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
65
+ display_impacts(impacts)
66
 
67
+ with st.container(border=False):
68
+ st.markdown('<h3 align = "center">Equivalences</h3>', unsafe_allow_html=True)
 
69
  st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
70
+ page = st.radio(' ', ['Energy' , 'GHG'], horizontal=True)
71
+
72
+ with st.container(border=True):
73
+ if page == 'Energy' :
74
+ display_equivalent_energy(impacts)
75
+ else :
76
+ display_equivalent_ghg(impacts)
77
+
78
 
79
  except Exception as e:
80
  st.error('Could not find the model in the repository. Please try another model.')