Class: Telnyx::Resources::AI::Collections
- Inherits:
-
Object
- Object
- Telnyx::Resources::AI::Collections
- 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
Instance Attribute Summary collapse
-
#settings ⇒ Telnyx::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.
-
#sources ⇒ Telnyx::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.
Instance Method Summary collapse
-
#create(name:, description: nil, settings: nil, slug: nil, sources: nil, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope
Creates a new collection scoped to your organization.
-
#delete(uuid, request_options: {}) ⇒ nil
Soft-deletes a collection.
-
#initialize(client:) ⇒ Collections
constructor
private
A new instance of Collections.
-
#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.
-
#retrieve(slug, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope
Fetches a single collection by its
slug. -
#retrieve_by_id(uuid, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope
Fetches a single collection by its
uuid. -
#retrieve_documents(slug, filter: nil, page_number: nil, page_size: nil, query: nil, retrieval_type: nil, sources: nil, top_k: nil, request_options: {}) ⇒ Telnyx::Models::AI::CollectionRetrieveDocumentsResponse
Some parameter documentations has been truncated, see Models::AI::CollectionRetrieveDocumentsParams for more details.
-
#update(uuid, description: nil, name: nil, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope
Updates a collection's metadata (
nameand/ordescription).
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.
236 237 238 239 240 |
# File 'lib/telnyx/resources/ai/collections.rb', line 236 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
#settings ⇒ Telnyx::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 |
#sources ⇒ Telnyx::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.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/telnyx/resources/ai/collections.rb', line 40 def create(params) parsed, = Telnyx::AI::CollectionCreateParams.dump_request(params) @client.request( method: :post, path: "ai/collections", body: parsed, model: Telnyx::AI::CollectionEnvelope, options: ) end |
#delete(uuid, request_options: {}) ⇒ nil
Soft-deletes a collection. Its slug is freed and may be reused by a new
collection.
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.
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, = 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: ) end |
#retrieve(slug, request_options: {}) ⇒ Telnyx::Models::AI::CollectionEnvelope
Fetches a single collection by its slug.
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.
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 |
#retrieve_documents(slug, filter: nil, page_number: nil, page_size: nil, query: nil, retrieval_type: nil, sources: nil, top_k: nil, request_options: {}) ⇒ Telnyx::Models::AI::CollectionRetrieveDocumentsResponse
Some parameter documentations has been truncated, see Models::AI::CollectionRetrieveDocumentsParams for more details.
Runs search over the documents in a collection, ranked by relevance to query.
The collection's retrieval_type setting selects the strategy: vector
(semantic similarity), hybrid (vector similarity fused with keyword matching),
or keyword (lexical BM25 matching). When query is omitted, returns a plain
catalog listing of the collection's documents.
How it works:
- For
vectorandhybrid, thequerytext is embedded into a 1024-dimensional vector using the multilingual-e5-large model. - For
vector, the embedding is compared against the collection's indexed document chunks using semantic similarity; forhybrid, those similarity scores are fused with keyword-match scores; forkeyword, only lexical BM25 matching is applied. - Results are ranked by
score(descending) and paginated viapage[number]/page[size].
Authentication: Requires a Telnyx API key via Authorization: Bearer <key>.
Results are automatically scoped to your organization and cannot be overridden.
Filtering: Use filter[field][operator]=value query parameters to narrow
results before search. Supported operators: eq (default), in, gte, gt,
lte, lt, contains. Metadata fields resolve to metadata.<field>.
Examples:
GET /v2/ai/collections/my-collection/documents?query=billing+issue&top_k=10GET /v2/ai/collections/my-collection/documents?query=refund&sources=voice,messageGET /v2/ai/collections/my-collection/documents?query=outage&filter[record_created_at][gte]=2026-01-01T00:00:00Z
221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/telnyx/resources/ai/collections.rb', line 221 def retrieve_documents(slug, params = {}) parsed, = Telnyx::AI::CollectionRetrieveDocumentsParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["ai/collections/%1$s/documents", slug], query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"), model: Telnyx::Models::AI::CollectionRetrieveDocumentsResponse, 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.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/telnyx/resources/ai/collections.rb', line 87 def update(uuid, params = {}) parsed, = Telnyx::AI::CollectionUpdateParams.dump_request(params) @client.request( method: :patch, path: ["ai/collections/%1$s", uuid], body: parsed, model: Telnyx::AI::CollectionEnvelope, options: ) end |