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:



108
109
110
111
# File 'lib/openai/resources/conversations.rb', line 108

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
# 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,
    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:



96
97
98
99
100
101
102
103
# File 'lib/openai/resources/conversations.rb', line 96

def delete(conversation_id, params = {})
  @client.request(
    method: :delete,
    path: ["conversations/%1$s", conversation_id],
    model: OpenAI::Conversations::ConversationDeletedResource,
    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:



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

def retrieve(conversation_id, params = {})
  @client.request(
    method: :get,
    path: ["conversations/%1$s", conversation_id],
    model: OpenAI::Conversations::Conversation,
    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:



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

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,
    options: options
  )
end