yera.cli.setup_handlers.openai

OpenAI provider setup handler.

Symbols

class OpenAISetup — Handler for configuring OpenAI provider connections.

OpenAISetup

Handler for configuring OpenAI provider connections.

This class implements the logic required to discover, prompt for, and validate the environment variables used to authenticate with OpenAI's API.

Methods

detect_config — Detect and report an OpenAI connection from the environment.
ask_for_config — Interactively prompts the user to configure an OpenAI connection.
validate — Validate an OpenAI connection through the reusable setup operation.

OpenAISetup.detect_config

detect_config() → OpenAIConnection | None

Detect and report an OpenAI connection from the environment.

Returns

type: OpenAIConnection | None

A detected OpenAI connection, or None when no conventional API-key environment variable is present.

OpenAISetup.ask_for_config

ask_for_config() → OpenAIConnection | None

Interactively prompts the user to configure an OpenAI connection.

First asks the user for confirmation to proceed, then prompts for the name of the environment variable that holds the API key.

Returns

type: OpenAIConnection | None

An OpenAIConnection instance containing the user-specified environment variable name, or None if the user declines the setup.

OpenAISetup.validate

validate(
    config: OpenAIConnection,
) → None

Validate an OpenAI connection through the reusable setup operation.

Parameters

config
type: OpenAIConnection

OpenAI connection to validate.

Raises

ValueError

If its API-key environment variable is absent or malformed.