OpenAIService

General-purpose service for interacting with the OpenAI API.

Must be initialized with initialize before use. If not configured (no API key), methods will gracefully return null.

See also

for configuration options

Properties

Link copied to clipboard

Circuit breaker for the OpenAI SDK client (Jeeves, startup joke).

Link copied to clipboard

Rate limiter for the OpenAI SDK client.

Functions

Link copied to clipboard
fun generateCompletion(prompt: String, model: String): String?

Sends a prompt to the specified model and returns the completion text.

Link copied to clipboard

Generates the punchline of a knock-knock joke using the high-quality model.

Link copied to clipboard

Generates the setup half of a knock-knock joke using the low-cost model.

Link copied to clipboard
fun getClient(): OpenAIClient?

Returns the underlying OpenAI client, or null if not initialized.

Link copied to clipboard

Returns the current configuration, or null if not initialized.

Link copied to clipboard
fun initialize(lorekeeperConfig: LorekeeperConfig)

Initializes the OpenAI client with the provided configuration.

Link copied to clipboard

Returns true if the OpenAI client is initialized and ready.