_ecologits
EcoLogits
EcoLogits instrumentor to initialize function patching for each provider.
By default, the initialization will be done on all available and compatible providers that are supported by the library.
Examples:
EcoLogits initialization example with OpenAI.
from ecologits import EcoLogits
from openai import OpenAI
EcoLogits.init()
client = OpenAI(api_key="<OPENAI_API_KEY>")
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Tell me a funny joke!"}
]
)
# Get estimated environmental impacts of the inference
print(f"Energy consumption: {response.impacts.energy.value} kWh")
print(f"GHG emissions: {response.impacts.gwp.value} kgCO2eq")
init(providers=None, electricity_mix_zone='WOR')
staticmethod
Initialization static method. Will attempt to initialize all providers by default.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
providers |
Optional[Union[str, list[str]]]
|
list of providers to initialize (all providers by default). |
None
|
electricity_mix_zone |
str
|
ISO 3166-1 alpha-3 code of the electricity mix zone (WOR by default). |
'WOR'
|