Class: WhopSDK::Resources::AIChats

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/ai_chats.rb

Overview

Ai chats

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ AIChats

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

Parameters:



161
162
163
# File 'lib/whop_sdk/resources/ai_chats.rb', line 161

def initialize(client:)
  @client = client
end

Instance Method Details

#create(message_text:, current_company_id: nil, message_attachments: nil, message_source: nil, suggestion_type: nil, title: nil, request_options: {}) ⇒ WhopSDK::Models::AIChat

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

Create a new AI chat thread and send the first message to the AI agent.

Required permissions:

  • ‘ai_chat:create`

Parameters:

  • message_text (String)

    The text content of the first message to send to the AI agent.

  • current_company_id (String, nil)

    The unique identifier of the company to set as context for the AI chat (e.g., “b

  • message_attachments (Array<WhopSDK::Models::AIChatCreateParams::MessageAttachment>, nil)

    A list of previously uploaded file attachments to include with the first message

  • message_source (Symbol, WhopSDK::Models::AIChatCreateParams::MessageSource, nil)

    The source of an AI chat message

  • suggestion_type (String, nil)

    The type of suggestion prompt that was clicked, when message_source is ‘suggesti

  • title (String, nil)

    An optional display title for the AI chat thread (e.g., “Help with billing”).

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

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
# File 'lib/whop_sdk/resources/ai_chats.rb', line 35

def create(params)
  parsed, options = WhopSDK::AIChatCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "ai_chats",
    body: parsed,
    model: WhopSDK::AIChat,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ Boolean

Delete an AI chat thread so it no longer appears in the user’s chat list.

Required permissions:

  • ‘ai_chat:delete`

Parameters:

  • id (String)

    The unique identifier of the AI chat to delete (e.g., “ai_chat_XXXXX”).

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

Returns:

  • (Boolean)

See Also:



149
150
151
152
153
154
155
156
# File 'lib/whop_sdk/resources/ai_chats.rb', line 149

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["ai_chats/%1$s", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end

#list(after: nil, before: nil, first: nil, last: nil, only_active_crons: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::AIChatListResponse>

Returns a paginated list of AI chat threads for the current authenticated user.

Parameters:

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • only_active_crons (Boolean, nil)

    When true, returns only chats with an active cron schedule

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

Returns:

See Also:



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/whop_sdk/resources/ai_chats.rb', line 121

def list(params = {})
  parsed, options = WhopSDK::AIChatListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "ai_chats",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::AIChatListResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::AIChat

Retrieves the details of an existing AI chat.

Parameters:

  • id (String)

    The unique identifier of the AI chat to retrieve.

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

Returns:

See Also:



57
58
59
60
61
62
63
64
# File 'lib/whop_sdk/resources/ai_chats.rb', line 57

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["ai_chats/%1$s", id],
    model: WhopSDK::AIChat,
    options: params[:request_options]
  )
end

#update(id, current_company_id: nil, notification_preference: nil, title: nil, request_options: {}) ⇒ WhopSDK::Models::AIChat

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

Update an AI chat’s title, notification preferences, or associated company context.

Required permissions:

  • ‘ai_chat:update`

Parameters:

  • id (String)

    The unique identifier of the AI chat to update (e.g., “ai_chat_XXXXX”).

  • current_company_id (String, nil)

    The unique identifier of the company to set as context for the AI chat (e.g., “b

  • notification_preference (Symbol, WhopSDK::Models::NotificationPreferences, nil)

    The notification preference for an AI chat

  • title (String, nil)

    The new display title for the AI chat thread (e.g., “Help with billing”).

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

Returns:

See Also:



91
92
93
94
95
96
97
98
99
100
# File 'lib/whop_sdk/resources/ai_chats.rb', line 91

def update(id, params = {})
  parsed, options = WhopSDK::AIChatUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["ai_chats/%1$s", id],
    body: parsed,
    model: WhopSDK::AIChat,
    options: options
  )
end