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
88 stars 9 forks source link

Support formatting for Range values #83

Closed samuelrince closed 1 week ago

samuelrince commented 1 month 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 1 month ago

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