Class: OpenAI::Resources::Beta::Threads::Messages Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/beta/threads/messages.rb,
sig/openai/resources/beta/threads/messages.rbs

Overview

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Build Assistants that can call models and use tools.

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:



224
225
226
# File 'lib/openai/resources/beta/threads/messages.rb', line 224

def initialize(client:)
  @client = client
end

Instance Method Details

#create(thread_id, content:, role:, attachments: nil, metadata: nil, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Message

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Create a message.

Parameters:

Returns:

See Also:



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/openai/resources/beta/threads/messages.rb', line 49

def create(thread_id, params)
  parsed, options = OpenAI::Beta::Threads::MessageCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["threads/%1$s/messages", thread_id],
    body: parsed,
    model: OpenAI::Beta::Threads::Message,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#delete(message_id, thread_id:, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::MessageDeleted

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Deletes a message.

Parameters:

  • message_id (String)

    The ID of the message to delete.

  • thread_id (String)

    The ID of the thread to which this message belongs.

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

Returns:

See Also:



206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/openai/resources/beta/threads/messages.rb', line 206

def delete(message_id, params)
  parsed, options = OpenAI::Beta::Threads::MessageDeleteParams.dump_request(params)
  thread_id = parsed.delete(:thread_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :delete,
    path: ["threads/%1$s/messages/%2$s", thread_id, message_id],
    model: OpenAI::Beta::Threads::MessageDeleted,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#list(thread_id, after: nil, before: nil, limit: nil, order: nil, run_id: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::Beta::Threads::Message>

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Returns a list of messages for a given thread.

Parameters:

  • thread_id (String)

    The ID of the thread the messages belong to.

  • after (String)

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before (String)

    A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

  • limit (Integer)

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • order (Symbol, OpenAI::Models::Beta::Threads::MessageListParams::Order)

    Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

  • run_id (String)

    Filter messages by the run ID that generated them.

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

Returns:

See Also:



175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/openai/resources/beta/threads/messages.rb', line 175

def list(thread_id, params = {})
  parsed, options = OpenAI::Beta::Threads::MessageListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["threads/%1$s/messages", thread_id],
    query: query,
    page: OpenAI::Internal::CursorPage,
    model: OpenAI::Beta::Threads::Message,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#retrieve(message_id, thread_id:, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Message

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Retrieve a message.

Parameters:

  • message_id (String)

    The ID of the message to retrieve.

  • thread_id (String)

    The ID of the thread to which this message belongs.

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

Returns:

See Also:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/openai/resources/beta/threads/messages.rb', line 80

def retrieve(message_id, params)
  parsed, options = OpenAI::Beta::Threads::MessageRetrieveParams.dump_request(params)
  thread_id = parsed.delete(:thread_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :get,
    path: ["threads/%1$s/messages/%2$s", thread_id, message_id],
    model: OpenAI::Beta::Threads::Message,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#update(message_id, thread_id:, metadata: nil, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Message

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Modifies a message.

Parameters:

  • message_id (String)

    Path param: The ID of the message to modify.

  • thread_id (String)

    Path param: The ID of the thread to which this message belongs.

  • metadata (Hash{Symbol=>String}, nil)

    Body param: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.

    Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

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

Returns:

See Also:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/openai/resources/beta/threads/messages.rb', line 120

def update(message_id, params)
  parsed, options = OpenAI::Beta::Threads::MessageUpdateParams.dump_request(params)
  thread_id = parsed.delete(:thread_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :post,
    path: ["threads/%1$s/messages/%2$s", thread_id, message_id],
    body: parsed,
    model: OpenAI::Beta::Threads::Message,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end