Class: OpenAI::Resources::Chat::Completions::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/chat/completions/messages.rb

Overview

Given a list of messages comprising a conversation, the model will return a response.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Messages

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.

Returns a new instance of Messages.

Parameters:



47
48
49
# File 'lib/openai/resources/chat/completions/messages.rb', line 47

def initialize(client:)
  @client = client
end

Instance Method Details

#list(completion_id, after: nil, limit: nil, order: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::Chat::ChatCompletionStoreMessage>

Some parameter documentations has been truncated, see Models::Chat::Completions::MessageListParams for more details.

Get the messages in a stored chat completion. Only Chat Completions that have been created with the ‘store` parameter set to `true` will be returned.

Parameters:

  • completion_id (String)

    The ID of the chat completion to retrieve messages from.

  • after (String)

    Identifier for the last message from the previous pagination request.

  • limit (Integer)

    Number of messages to retrieve.

  • order (Symbol, OpenAI::Models::Chat::Completions::MessageListParams::Order)

    Sort order for messages by timestamp. Use ‘asc` for ascending order or `desc` fo

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/openai/resources/chat/completions/messages.rb', line 31

def list(completion_id, params = {})
  parsed, options = OpenAI::Chat::Completions::MessageListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["chat/completions/%1$s/messages", completion_id],
    query: query,
    page: OpenAI::Internal::CursorPage,
    model: OpenAI::Chat::ChatCompletionStoreMessage,
    options: options
  )
end