Ilyas KHIAT commited on
Commit
b8f7efd
1 Parent(s): 0dc8c45

emission detailed

Browse files
chat_with_pps.py CHANGED
@@ -217,7 +217,7 @@ def dowmload_history(used_models=None):
217
  summary = ''.join(summary)
218
  pdf = export_conversation(AIMessage(content=summary).content,used_models=used_models)
219
 
220
- st.session_state["partial_emissions"]["download_rapport"]["cc"] += st.session_state["emission"].stop()
221
 
222
  if pdf:
223
  st.download_button("Télécharger le PDF", data=pdf, file_name=f"Cartographie {brand_name}.pdf", mime="application/pdf")
@@ -395,7 +395,7 @@ def display_chat():
395
  with st.spinner("Proposition de prompts..."):
396
  propositions_prompts = get_response_with_impact(generated_prompt_question, st.session_state.chat_history,format_context(st.session_state['pp_grouped'],st.session_state['Nom de la marque']),st.session_state.model,history_limit=1,stream=False)
397
  extract_format_prompts_from_response(propositions_prompts)
398
- st.session_state["partial_emissions"]["chatbot"]["cc"] += st.session_state["emission"].stop()
399
 
400
 
401
 
@@ -428,7 +428,7 @@ def display_chat():
428
  with st.spinner("Proposition de prompts..."):
429
  propositions_prompts = get_response_with_impact(generated_prompt_question, st.session_state.chat_history,format_context(st.session_state['pp_grouped'],st.session_state['Nom de la marque']),st.session_state.model,history_limit=1,stream=False)
430
  extract_format_prompts_from_response(propositions_prompts)
431
- st.session_state["partial_emissions"]["chatbot"]["cc"] += st.session_state["emission"].stop()
432
 
433
 
434
 
 
217
  summary = ''.join(summary)
218
  pdf = export_conversation(AIMessage(content=summary).content,used_models=used_models)
219
 
220
+ st.session_state["partial_emissions"]["download_rapport"]["cc"] = st.session_state["emission"].stop()
221
 
222
  if pdf:
223
  st.download_button("Télécharger le PDF", data=pdf, file_name=f"Cartographie {brand_name}.pdf", mime="application/pdf")
 
395
  with st.spinner("Proposition de prompts..."):
396
  propositions_prompts = get_response_with_impact(generated_prompt_question, st.session_state.chat_history,format_context(st.session_state['pp_grouped'],st.session_state['Nom de la marque']),st.session_state.model,history_limit=1,stream=False)
397
  extract_format_prompts_from_response(propositions_prompts)
398
+ st.session_state["partial_emissions"]["chatbot"]["cc"] = st.session_state["emission"].stop()
399
 
400
 
401
 
 
428
  with st.spinner("Proposition de prompts..."):
429
  propositions_prompts = get_response_with_impact(generated_prompt_question, st.session_state.chat_history,format_context(st.session_state['pp_grouped'],st.session_state['Nom de la marque']),st.session_state.model,history_limit=1,stream=False)
430
  extract_format_prompts_from_response(propositions_prompts)
431
+ st.session_state["partial_emissions"]["chatbot"]["cc"] = st.session_state["emission"].stop()
432
 
433
 
434
 
comparateur.py CHANGED
@@ -18,6 +18,18 @@ def display_comparaison(container,value_init, ratio_equivalent,icon, unit):
18
  container.markdown(f"<div style='text-align: center;'><a href='{link_url}' target='_blank'><img src='{icon}' alt='{unit}' width='50'></div>", unsafe_allow_html=True)
19
  container.markdown(f"<div style='text-align: center;'><b>{compare(value_init, ratio_equivalent):.2f}</b> {unit}</div>", unsafe_allow_html=True)
20
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  def get_table_empreintes_detailed() -> pd.DataFrame:
22
  emissions_data = st.session_state["partial_emissions"]
23
  emissions_df = pd.DataFrame(emissions_data).T # Transpose to match the desired format
@@ -35,7 +47,8 @@ def get_table_empreintes_detailed() -> pd.DataFrame:
35
  })
36
 
37
  # Make Ecologits column cumulative
38
- emissions_df["EcoLogits (Cumulative)"] = emissions_df["EcoLogits (par requete)"].cumsum()
 
39
  emissions_df['Consommation Totale'] = emissions_df["CodeCarbon (Cumulative)"] + emissions_df["EcoLogits (Cumulative)"]
40
 
41
  return emissions_df
 
18
  container.markdown(f"<div style='text-align: center;'><a href='{link_url}' target='_blank'><img src='{icon}' alt='{unit}' width='50'></div>", unsafe_allow_html=True)
19
  container.markdown(f"<div style='text-align: center;'><b>{compare(value_init, ratio_equivalent):.2f}</b> {unit}</div>", unsafe_allow_html=True)
20
 
21
+ def custom_cumsum(ecologits_series, codecarbon_series):
22
+ cumsum = 0
23
+ result = []
24
+ for eco, code in zip(ecologits_series, codecarbon_series):
25
+ if code == 0:
26
+ result.append(0)
27
+ else:
28
+ cumsum += eco
29
+ result.append(cumsum)
30
+ return pd.Series(result, index=ecologits_series.index)
31
+
32
+
33
  def get_table_empreintes_detailed() -> pd.DataFrame:
34
  emissions_data = st.session_state["partial_emissions"]
35
  emissions_df = pd.DataFrame(emissions_data).T # Transpose to match the desired format
 
47
  })
48
 
49
  # Make Ecologits column cumulative
50
+ emissions_df["Ecologits (Cumulative)"] = custom_cumsum(emissions_df["Ecologits (par requete)"], emissions_df["CodeCarbon (Cumulative)"])
51
+
52
  emissions_df['Consommation Totale'] = emissions_df["CodeCarbon (Cumulative)"] + emissions_df["EcoLogits (Cumulative)"]
53
 
54
  return emissions_df
documentations.py CHANGED
@@ -28,5 +28,3 @@ def display_documentation():
28
  </div>
29
  """, unsafe_allow_html=True)
30
 
31
- if __name__ == "__main__":
32
- main()
 
28
  </div>
29
  """, unsafe_allow_html=True)
30
 
 
 
emissions.csv CHANGED
@@ -1261,4 +1261,8 @@ timestamp,project_name,run_id,duration,emissions,emissions_rate,cpu_power,gpu_po
1261
  2024-07-16T16:49:50,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,485.6137709617615,0.0005883974325668,1.2116572217495226e-06,42.5,71.56429094944244,5.86829710006714,0.0057327525291177,0.000408490049014,0.0007909483356023,0.0069321909137341,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
1262
  2024-07-16T16:49:54,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,489.5490849018097,0.0005934516480259,1.2122413590968472e-06,42.5,6.164566106237397,5.86829710006714,0.0057791874955097,0.000415223665512,0.0007973258767141,0.0069917370377359,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
1263
  2024-07-16T16:49:58,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,492.887193441391,0.0005980930229806,1.2134480890133714e-06,42.5,10.687664072342644,5.86829710006714,0.0058185721794764,0.000425118951206,0.0008027281600799,0.0070464192907623,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
1264
- 2024-07-16T16:50:26,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,520.8702492713928,0.0006319792123063716,1.2133140896228973e-06,42.5,2.998423125311832,5.86829710006714,0.006148915880918504,0.000448423414294,0.0008483093611850917,0.007445648656397595,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
 
 
 
 
 
1261
  2024-07-16T16:49:50,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,485.6137709617615,0.0005883974325668,1.2116572217495226e-06,42.5,71.56429094944244,5.86829710006714,0.0057327525291177,0.000408490049014,0.0007909483356023,0.0069321909137341,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
1262
  2024-07-16T16:49:54,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,489.5490849018097,0.0005934516480259,1.2122413590968472e-06,42.5,6.164566106237397,5.86829710006714,0.0057791874955097,0.000415223665512,0.0007973258767141,0.0069917370377359,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
1263
  2024-07-16T16:49:58,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,492.887193441391,0.0005980930229806,1.2134480890133714e-06,42.5,10.687664072342644,5.86829710006714,0.0058185721794764,0.000425118951206,0.0008027281600799,0.0070464192907623,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
1264
+ 2024-07-16T16:50:26,codecarbon,8f166622-2047-4c8f-a0f0-b79b8a86624f,520.8702492713928,0.0006319792123063,1.2133140896228973e-06,42.5,2.998423125311832,5.86829710006714,0.0061489158809185,0.000448423414294,0.000848309361185,0.0074456486563975,France,FRA,nouvelle-aquitaine,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,-0.6455,44.8152,15.648792266845703,machine,N,1.0
1265
+ 2024-07-17T04:45:33,codecarbon,622362d5-0dd3-46ad-b4d1-0695b0ab246c,0.1201128959655761,9.616513641056195e-07,8.006229109497325e-06,42.5,36.04407522618436,5.86829710006714,1.3950092924965754e-06,1.1625009300013367e-06,1.566499148556962e-07,2.714160137353608e-06,The Netherlands,NLD,north holland,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,4.8975,52.3759,15.648792266845703,machine,N,1.0
1266
+ 2024-07-17T06:35:33,codecarbon,6cbdf6ff-7b28-4c26-932a-4d60547eaa4a,0.0481524467468261,5.539118342312675e-07,1.150329571295932e-05,42.5,75.20749278422755,5.86829710006714,5.567967891693116e-07,9.64167437996627e-07,4.239384229113815e-08,1.5633580694570767e-06,The Netherlands,NLD,north holland,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,4.8975,52.3759,15.648792266845703,machine,N,1.0
1267
+ 2024-07-17T06:36:18,codecarbon,6cbdf6ff-7b28-4c26-932a-4d60547eaa4a,44.37114143371582,0.0002649085093829,5.970288363635892e-06,42.5,12.237726790269791,5.86829710006714,0.0005238025150365,0.000151617343516,7.225663113008012e-05,0.0007476764896826,The Netherlands,NLD,north holland,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,4.8975,52.3759,15.648792266845703,machine,N,1.0
1268
+ 2024-07-17T08:59:49,codecarbon,6cbdf6ff-7b28-4c26-932a-4d60547eaa4a,8655.962862968445,0.041333712164555836,4.775172077203321e-06,42.5,0.0878967331304106,5.86829710006714,0.10218842700537709,0.0003618758450559985,0.014109765520835576,0.11666006837126866,The Netherlands,NLD,north holland,,,Windows-11-10.0.22631-SP0,3.12.3,2.5.0,16.0,12th Gen Intel(R) Core(TM) i5-12500H,1.0,1 x NVIDIA GeForce RTX 4050 Laptop GPU,4.8975,52.3759,15.648792266845703,machine,N,1.0
high_chart.py CHANGED
@@ -197,5 +197,5 @@ def test_chart():
197
 
198
  if col1.button("Sauvegarder",key="save"):
199
  st.session_state['pp_grouped'] = chart.copy()
200
- st.session_state["partial_emissions"]["cartographie"]["cc"] += st.session_state["emission"].stop()
201
  return "saved"
 
197
 
198
  if col1.button("Sauvegarder",key="save"):
199
  st.session_state['pp_grouped'] = chart.copy()
200
+ st.session_state["partial_emissions"]["cartographie"]["cc"] = st.session_state["emission"].stop()
201
  return "saved"
partie_prenante_carte.py CHANGED
@@ -379,7 +379,7 @@ def display_pp():
379
  st.session_state["latest_doc"] = ""
380
  else:
381
  # Création de l'expander
382
- st.session_state["partial_emissions"]["Scrapping"]["cc"] += st.session_state["emission"].stop()
383
  st.session_state["latest_doc"] = docs
384
 
385
  with st.spinner("Processing..."):
@@ -399,7 +399,7 @@ def display_pp():
399
  partie_prenante = sorted(partie_prenante)
400
  st.session_state["urls"].append(url)
401
  add_pp(partie_prenante)
402
- st.session_state["partial_emissions"]["extraction_pp"]["cc"] += st.session_state["emission"].stop()
403
 
404
 
405
  # alphabet = [ pp[0] for pp in partie_prenante]
 
379
  st.session_state["latest_doc"] = ""
380
  else:
381
  # Création de l'expander
382
+ st.session_state["partial_emissions"]["Scrapping"]["cc"] = st.session_state["emission"].stop()
383
  st.session_state["latest_doc"] = docs
384
 
385
  with st.spinner("Processing..."):
 
399
  partie_prenante = sorted(partie_prenante)
400
  st.session_state["urls"].append(url)
401
  add_pp(partie_prenante)
402
+ st.session_state["partial_emissions"]["extraction_pp"]["cc"] = st.session_state["emission"].stop()
403
 
404
 
405
  # alphabet = [ pp[0] for pp in partie_prenante]