Skip to content

Adding the possibility to load a configuration instead of init parameters #98

@NP4567-dev

Description

@NP4567-dev

Description

Context:
In this first issue on the topic, the aim is to enable the user to provide a configuration for both existing parameters (providers and electricity_mix_zone).
The addition of other configuration parameters, while taken into account will be addressed in other issues
It is important to stay compatible with older versions while guaranteeing enough flexibility to implement future configuration features.

Changes:
Add the configuration argument. It is a path pointing to a locally stored yaml configuration in Ecologits.init().
The file could have the following formatting for now:

providers:
    - mistral
    - openai
electricity_mix_zone: WOR

I see three possible ways to handle it:

  • Ecologits.init() now expects a _Config: this is pretty simple but not retrocompatible and would probably remove some typing helps for users
  • Ecologits.init() can now handle either the current parameters or a _Config parameter. This means the priority between arguments must be set (if both a config and current parameters are provided, which value is kept?). Also, for each additionnal parameter handled by the configuration, it will start a discussion on wether it should be added to the base parameters of the init function
  • Add a different 'init_with_config' function, expecting a _Config object to the Ecologits class. This goes towards having different uses in experimental and production settings for users, but also might be a bit harder to maintain.

These questions have to be answered before proceeding:

  • Should an unvalid configuration (non existing provider or electricity mix) raise an exception from the get go?
  • Should a missing parameter (neither key nor value in yaml) in configuration be replaced by a default value? (in the future wether to fallback on default values could be a parameter)
  • Should an empty parameter (key but empty value in yaml) in configuration be considered an error from the user and raise an exception?
  • What should be the specific value for when the user wants all the providers to be loaded? It could be just a null value or a specific word.

Other remarks:
Not in this feature but could be added later:

  • Having a specific electricity_mix for a given provider
  • Providing custom model infos
  • Error handling configuration (should a missing info raise an error or just be loggued)
  • ...

Feel free to correct or add anything 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions