Class: LittleGhost::Providers::OpenAI
- Inherits:
-
OpenAICompatible
- Object
- Base
- OpenAICompatible
- LittleGhost::Providers::OpenAI
- Defined in:
- lib/little_ghost/providers/openai.rb
Overview
OpenAI connects LittleGhost features to OpenAI models for generation and embeddings. Generation uses the Responses API by default and supports streaming, Tools, and structured results.
provider = LittleGhost::Providers::OpenAI.new(
api_key: ENV.fetch("OPENAI_API_KEY"),
model: ENV.fetch("OPENAI_MODEL")
)
Supply api: :chat_completions only when a model or integration requires the Chat Completions wire API.
Constant Summary collapse
- DEFAULT_BASE_URL =
The OpenAI API endpoint used when
base_urlis omitted. "https://api.openai.com/v1/"- DEFAULT_MAX_EMBEDDING_RESPONSE_BYTES =
:nodoc:
OpenAICompatible::DEFAULT_MAX_EMBEDDING_RESPONSE_BYTES
Constants inherited from OpenAICompatible
LittleGhost::Providers::OpenAICompatible::CONTEXT_OVERFLOW_MARKERS, LittleGhost::Providers::OpenAICompatible::INITIAL_RETRY_DELAY, LittleGhost::Providers::OpenAICompatible::MAX_RETRY_DELAY, LittleGhost::Providers::OpenAICompatible::TRANSIENT_STREAM_ERROR_TYPES
Instance Attribute Summary
Attributes inherited from OpenAICompatible
Instance Method Summary collapse
-
#initialize(base_url: DEFAULT_BASE_URL, **arguments) ⇒ OpenAI
constructor
Uses the official OpenAI API base URL by default.
Methods inherited from OpenAICompatible
#capabilities, #embed, request_options, #stream
Methods inherited from Base
#capabilities, #embed, #prepare_request, request_options, #stream
Constructor Details
#initialize(base_url: DEFAULT_BASE_URL, **arguments) ⇒ OpenAI
Uses the official OpenAI API base URL by default.
24 |
# File 'lib/little_ghost/providers/openai.rb', line 24 def initialize(base_url: DEFAULT_BASE_URL, **arguments) = super |