Skip to content

Make openai_api_key optional in config #61

@cybardev

Description

@cybardev

The chatgpt.openai_api_key config option should be optional imo, since local OpenAI-compatible models (usually) don't need it. I'm using LM Studio and had to set that option to empty string. Otherwise getting this error:

Can not find the openai api key
You need to define one whether in the configuration file or as an environment variable

I think changing https://github.com/pythops/tenere/blob/15560b8ec/src/chatgpt.rs#L28-L41 to the following should work:

let openai_api_key = match std::env::var("OPENAI_API_KEY") {
    Ok(key) => key,
    Err(_) => config
        .openai_api_key
        .unwrap_or(""),
};

Alternatively there could be a chatgpt.local boolean option, which, if true, makes the API key optional. But I think the empty string way is better, and if someone leaves it empty for online models, we already get a 401 Unauthorized message.

If you're okay with this, I can make a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions