Class: OpenAI::Resources::Conversations

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/conversations.rb,
lib/openai/resources/conversations/items.rb,
sig/openai/resources/conversations.rbs,
sig/openai/resources/conversations/items.rbs

Overview

Manage conversations and conversation items.

Defined Under Namespace

Classes: Items

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Conversations

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

Parameters:



123
124
125
126
# File 'lib/openai/resources/conversations.rb', line 123

def initialize(client:)
  @client = client
  @items = OpenAI::Resources::Conversations::Items.new(client: client)
end

Instance Attribute Details

#itemsOpenAI::Resources::Conversations::Items (readonly)

Manage conversations and conversation items.



9
10
11
# File 'lib/openai/resources/conversations.rb', line 9

def items
  @items
end

Instance Method Details

#create(items: nil, metadata: nil, request_options: {}) ⇒ OpenAI::Models::Conversations::Conversation

Create a conversation.

Parameters:

Returns:

See Also:



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

def create(params = {})
  parsed, options = OpenAI::Conversations::ConversationCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "conversations",
    body: parsed,
    model: OpenAI::Conversations::Conversation,
    security: {bearer_auth: true},
    options: options
  )
end

#delete(conversation_id, request_options: {}) ⇒ OpenAI::Models::Conversations::ConversationDeletedResource

Delete a conversation. Items in the conversation will not be deleted.

Parameters:

  • conversation_id (String)

    The ID of the conversation to delete.

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

Returns:

See Also:



110
111
112
113
114
115
116
117
118
# File 'lib/openai/resources/conversations.rb', line 110

def delete(conversation_id, params = {})
  @client.request(
    method: :delete,
    path: ["conversations/%1$s", conversation_id],
    model: OpenAI::Conversations::ConversationDeletedResource,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end

#retrieve(conversation_id, request_options: {}) ⇒ OpenAI::Models::Conversations::Conversation

Get a conversation

Parameters:

  • conversation_id (String)

    The ID of the conversation to retrieve.

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

Returns:

See Also:



56
57
58
59
60
61
62
63
64
# File 'lib/openai/resources/conversations.rb', line 56

def retrieve(conversation_id, params = {})
  @client.request(
    method: :get,
    path: ["conversations/%1$s", conversation_id],
    model: OpenAI::Conversations::Conversation,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end

#update(conversation_id, metadata:, request_options: {}) ⇒ OpenAI::Models::Conversations::Conversation

Update a conversation

Parameters:

  • conversation_id (String)

    The ID of the conversation to update.

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

    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:



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/openai/resources/conversations.rb', line 86

def update(conversation_id, params)
  parsed, options = OpenAI::Conversations::ConversationUpdateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["conversations/%1$s", conversation_id],
    body: parsed,
    model: OpenAI::Conversations::Conversation,
    security: {bearer_auth: true},
    options: options
  )
end