Class: OpenAI::Resources::Conversations

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

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:



112
113
114
115
# File 'lib/openai/resources/conversations.rb', line 112

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

Some parameter documentations has been truncated, see Models::Conversations::ConversationCreateParams for more details.

Create a conversation.

Parameters:

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/openai/resources/conversations.rb', line 27

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:



99
100
101
102
103
104
105
106
107
# File 'lib/openai/resources/conversations.rb', line 99

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:



50
51
52
53
54
55
56
57
58
# File 'lib/openai/resources/conversations.rb', line 50

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

Some parameter documentations has been truncated, see Models::Conversations::ConversationUpdateParams for more details.

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

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

Returns:

See Also:



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/openai/resources/conversations.rb', line 76

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