Module: OpenAI::Internal::Type::BasePage Private
- Included in:
- ConversationCursorPage, CursorPage, NextCursorPage, Page
- Defined in:
- lib/openai/internal/type/base_page.rb,
sig/openai/internal/type/base_page.rbs
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This module provides a base implementation for paginated responses in the SDK.
Instance Attribute Summary collapse
-
#last_response ⇒ OpenAI::ResponseMetadata
readonly
Metadata from the HTTP response that produced this page.
Instance Method Summary collapse
-
#_request_id ⇒ String?
private
The ID of the API request, returned via the
x-request-idresponse header. - #auto_paging_each(&blk) {|, arg0| ... } ⇒ void
- #initialize(client:, req:, response_metadata:, page_data:) ⇒ Object private
- #next_page ⇒ self
- #next_page? ⇒ Boolean
- #to_enum ⇒ Enumerable<generic<Elem>> (also: #enum_for) private
Instance Attribute Details
#last_response ⇒ OpenAI::ResponseMetadata (readonly)
Metadata from the HTTP response that produced this page.
28 29 30 |
# File 'lib/openai/internal/type/base_page.rb', line 28 def last_response @last_response end |
Instance Method Details
#_request_id ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The ID of the API request, returned via the x-request-id response
header. This is only populated on top-level response objects returned
by the client.
21 |
# File 'lib/openai/internal/type/base_page.rb', line 21 def _request_id = last_response.request_id |
#auto_paging_each(&blk) {|, arg0| ... } ⇒ void
This method returns an undefined value.
47 |
# File 'lib/openai/internal/type/base_page.rb', line 47 def auto_paging_each(&blk) = (raise NotImplementedError) |
#initialize(client:, req:, response_metadata:, page_data:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/openai/internal/type/base_page.rb', line 60 def initialize(client:, req:, response_metadata:, page_data:) = req[:options].to_h query = OpenAI::Internal::Util .deep_merge(req[:query].to_h, [:extra_query].to_h) .to_h { |key, value| [key == "after" ? :after : key, value] } @client = client # Keep the effective query with a canonical cursor key, but clear its # higher-precedence copy so a page can replace the caller's original cursor. @req = { **req, query: query, options: {**, extra_query: {}} } @model = req.fetch(:model) @last_response = super() end |
#next_page ⇒ self
39 |
# File 'lib/openai/internal/type/base_page.rb', line 39 def next_page = (raise NotImplementedError) |
#next_page? ⇒ Boolean
33 |
# File 'lib/openai/internal/type/base_page.rb', line 33 def next_page? = (raise NotImplementedError) |
#to_enum ⇒ Enumerable<generic<Elem>> Also known as: enum_for
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 |
# File 'lib/openai/internal/type/base_page.rb', line 50 def to_enum = super(:auto_paging_each) |