genai-impact / ecologits

🌱 EcoLogits tracks the energy consumption and environmental footprint of using generative AI models through APIs.
https://ecologits.ai/
Mozilla Public License 2.0
78 stars 8 forks source link

Support formatting for Range values #83

Open samuelrince opened 2 weeks ago

samuelrince commented 2 weeks ago

Description

Support embedding Range values in f-strings. Currently, raises a TypeError exception.

TypeError: unsupported format string passed to Range.__format__

Example Code

from ecologits import EcoLogits
from openai import OpenAI

EcoLogits.init()

client = OpenAI(...)
response = client.chat.completions.create(...)

print(f"Energy consumption: {response.impacts.energy.value:.3f} kWh")
samuelrince commented 2 weeks ago

In addition, we could consider adding support for rounding Range values.