Class: OpenAI::Resources::Beta::Assistants

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/beta/assistants.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Assistants

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 Assistants.

Parameters:



174
175
176
# File 'lib/openai/resources/beta/assistants.rb', line 174

def initialize(client:)
  @client = client
end

Instance Method Details

#create(model: , description: nil, instructions: nil, metadata: nil, name: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_resources: nil, tools: nil, top_p: nil, request_options: {}) ⇒ OpenAI::Models::Beta::Assistant

Some parameter documentations has been truncated, see Models::Beta::AssistantCreateParams for more details.

Create an assistant with a model and instructions.

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
# File 'lib/openai/resources/beta/assistants.rb', line 41

def create(params)
  parsed, options = OpenAI::Beta::AssistantCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "assistants",
    body: parsed,
    model: OpenAI::Beta::Assistant,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#delete(assistant_id, request_options: {}) ⇒ OpenAI::Models::Beta::AssistantDeleted

Delete an assistant.

Parameters:

  • assistant_id (String)

    The ID of the assistant to delete.

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

Returns:

See Also:



162
163
164
165
166
167
168
169
# File 'lib/openai/resources/beta/assistants.rb', line 162

def delete(assistant_id, params = {})
  @client.request(
    method: :delete,
    path: ["assistants/%1$s", assistant_id],
    model: OpenAI::Beta::AssistantDeleted,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  )
end

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

Some parameter documentations has been truncated, see Models::Beta::AssistantListParams for more details.

Returns a list of assistants.

Parameters:

  • after (String)

    A cursor for use in pagination. ‘after` is an object ID that defines your place

  • before (String)

    A cursor for use in pagination. ‘before` is an object ID that defines your place

  • limit (Integer)

    A limit on the number of objects to be returned. Limit can range between 1 and 1

  • order (Symbol, OpenAI::Models::Beta::AssistantListParams::Order)

    Sort order by the ‘created_at` timestamp of the objects. `asc` for ascending ord

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

Returns:

See Also:



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/openai/resources/beta/assistants.rb', line 139

def list(params = {})
  parsed, options = OpenAI::Beta::AssistantListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "assistants",
    query: parsed,
    page: OpenAI::Internal::CursorPage,
    model: OpenAI::Beta::Assistant,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#retrieve(assistant_id, request_options: {}) ⇒ OpenAI::Models::Beta::Assistant

Retrieves an assistant.

Parameters:

  • assistant_id (String)

    The ID of the assistant to retrieve.

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

Returns:

See Also:



63
64
65
66
67
68
69
70
# File 'lib/openai/resources/beta/assistants.rb', line 63

def retrieve(assistant_id, params = {})
  @client.request(
    method: :get,
    path: ["assistants/%1$s", assistant_id],
    model: OpenAI::Beta::Assistant,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  )
end

#update(assistant_id, description: nil, instructions: nil, metadata: nil, model: nil, name: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_resources: nil, tools: nil, top_p: nil, request_options: {}) ⇒ OpenAI::Models::Beta::Assistant

Some parameter documentations has been truncated, see Models::Beta::AssistantUpdateParams for more details.

Modifies an assistant.

Parameters:

Returns:

See Also:



108
109
110
111
112
113
114
115
116
117
# File 'lib/openai/resources/beta/assistants.rb', line 108

def update(assistant_id, params = {})
  parsed, options = OpenAI::Beta::AssistantUpdateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["assistants/%1$s", assistant_id],
    body: parsed,
    model: OpenAI::Beta::Assistant,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end