Class: Telnyx::Resources::AI::Collections

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/collections.rb,
lib/telnyx/resources/ai/collections/sources.rb,
lib/telnyx/resources/ai/collections/settings.rb,
sig/telnyx/resources/ai/collections.rbs,
sig/telnyx/resources/ai/collections/sources.rbs,
sig/telnyx/resources/ai/collections/settings.rbs

Overview

Create and manage logical collections of your Telnyx data, tune retrieval settings, manage sources, and run collection-scoped semantic search.

Defined Under Namespace

Classes: Settings, Sources

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Collections

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

Parameters:



168
169
170
171
172
# File 'lib/telnyx/resources/ai/collections.rb', line 168

def initialize(client:)
  @client = client
  @settings = Telnyx::Resources::AI::Collections::Settings.new(client: client)
  @sources = Telnyx::Resources::AI::Collections::Sources.new(client: client)
end

Instance Attribute Details

#settingsTelnyx::Resources::AI::Collections::Settings (readonly)

Create and manage logical collections of your Telnyx data, tune retrieval settings, manage sources, and run collection-scoped semantic search.



12
13
14
# File 'lib/telnyx/resources/ai/collections.rb', line 12

def settings
  @settings
end

#sourcesTelnyx::Resources::AI::Collections::Sources (readonly)

Create and manage logical collections of your Telnyx data, tune retrieval settings, manage sources, and run collection-scoped semantic search.



17
18
19
# File 'lib/telnyx/resources/ai/collections.rb', line 17

def sources
  @sources
end

Instance Method Details

#create(name:, description: nil, settings: nil, slug: nil, sources: nil, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope

Creates a new collection scoped to your organization. Optionally attach sources and retrieval settings at creation time. If slug is omitted, one is derived from name and must be unique within your organization.

Parameters:

Returns:

See Also:



40
41
42
43
44
45
46
47
48
49
# File 'lib/telnyx/resources/ai/collections.rb', line 40

def create(params)
  parsed, options = Telnyx::AI::CollectionCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "ai/collections",
    body: parsed,
    model: Telnyx::AI::CollectionEnvelope,
    options: options
  )
end

#delete(uuid, request_options: {}) ⇒ nil

Soft-deletes a collection. Its slug is freed and may be reused by a new collection.

Parameters:

  • uuid (String)

    The collection's unique identifier.

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

Returns:

  • (nil)

See Also:



136
137
138
139
140
141
142
143
# File 'lib/telnyx/resources/ai/collections.rb', line 136

def delete(uuid, params = {})
  @client.request(
    method: :delete,
    path: ["ai/collections/%1$s", uuid],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::AI::Collection>

Returns a paginated list of collections in your organization.

Parameters:

  • page_number (Integer)

    Page number to return (1-based). Defaults to 1.

  • page_size (Integer)

    Number of results per page. Defaults to 20.

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

Returns:

See Also:



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/telnyx/resources/ai/collections.rb', line 111

def list(params = {})
  parsed, options = Telnyx::AI::CollectionListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "ai/collections",
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::AI::Collection,
    options: options
  )
end

#retrieve(slug, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope

Fetches a single collection by its slug.

Parameters:

  • slug (String)

    The collection's slug (unique within your organization).

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

Returns:

See Also:



62
63
64
65
66
67
68
69
# File 'lib/telnyx/resources/ai/collections.rb', line 62

def retrieve(slug, params = {})
  @client.request(
    method: :get,
    path: ["ai/collections/slug/%1$s", slug],
    model: Telnyx::AI::CollectionEnvelope,
    options: params[:request_options]
  )
end

#retrieve_by_id(uuid, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope

Fetches a single collection by its uuid.

Parameters:

  • uuid (String)

    The collection's unique identifier.

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

Returns:

See Also:



156
157
158
159
160
161
162
163
# File 'lib/telnyx/resources/ai/collections.rb', line 156

def retrieve_by_id(uuid, params = {})
  @client.request(
    method: :get,
    path: ["ai/collections/%1$s", uuid],
    model: Telnyx::AI::CollectionEnvelope,
    options: params[:request_options]
  )
end

#update(uuid, description: nil, name: nil, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope

Updates a collection's metadata (name and/or description). Sources and settings are managed through their own sub-resources.

Parameters:

  • uuid (String)

    The collection's unique identifier.

  • description (String)
  • name (String)
  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



87
88
89
90
91
92
93
94
95
96
# File 'lib/telnyx/resources/ai/collections.rb', line 87

def update(uuid, params = {})
  parsed, options = Telnyx::AI::CollectionUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["ai/collections/%1$s", uuid],
    body: parsed,
    model: Telnyx::AI::CollectionEnvelope,
    options: options
  )
end