ml3m.utils.openai: OpenAI-related utilities

ml3m.utils.openai.get_openai_config(config_path: str | Path) list[_OpenAIConfig][source]

Get the configurations for OpenAI.

Parameters

config_pathstr or pathlib.Path

The absolute path to the configuration file.

Returns

openai_configslist

The list of OpenAI configuration objects.

Examples

Assume that the configuration file .config/openai.json looks like the following:

[
    {
        "key": "sk-xxx1",
        "base": null,
        "n_workers": 30
    },
    {
        "key": "sk-xxx2",
        "base": "http://127.0.0.1/",
        "n_workers": 5
    }
]
>>> get_openai_config(".config/openai.json")  
[_OpenAIConfig <
    key sk-xxx1,
    base https://api.openai.com/v1,
    n_workers 30,
>, _OpenAIConfig <
    key sk-xxx2,
    base http://127.0.0.1/,
    n_workers 5,
>]