Class: Cadenya::Resources::Models

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/models.rb

Overview

Manage LLM models available to a workspace. Models represent provider and family pairs (e.g., “anthropic/claude-sonnet-4.6”). Workspaces are seeded with the supported models and you can enable or disable each one.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Models

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

Parameters:



144
145
146
# File 'lib/cadenya/resources/models.rb', line 144

def initialize(client:)
  @client = client
end

Instance Method Details

#list(workspace_id, ai_provider_key_id: nil, bundle_key: nil, cursor: nil, include_info: nil, limit: nil, prefix: nil, query: nil, sort_order: nil, status: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Model>

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

Lists all models in the workspace

Parameters:

  • workspace_id (String)

    Workspace ID.

  • ai_provider_key_id (String)

    Filter to models provisioned on a specific AI provider key. Accepts the

  • bundle_key (String)

    Filter by bundle_key — return only resources owned by this bundle.

  • cursor (String)

    Pagination cursor from previous response

  • include_info (Boolean)

    When true, populate each item’s info (e.g. the AI provider), at the cost of

  • limit (Integer)

    Maximum number of results to return

  • prefix (String)

    Filter by name prefix

  • query (String)

    Free-form search query

  • sort_order (String)

    Sort order for results (asc or desc by creation time)

  • status (Symbol, Cadenya::Models::ModelListParams::Status)

    Filter by model status

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

Returns:

See Also:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cadenya/resources/models.rb', line 68

def list(workspace_id, params = {})
  parsed, options = Cadenya::ModelListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/models", workspace_id],
    query: query.transform_keys(
      ai_provider_key_id: "aiProviderKeyId",
      bundle_key: "bundleKey",
      include_info: "includeInfo",
      sort_order: "sortOrder"
    ),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Model,
    options: options
  )
end

#retrieve(id, workspace_id:, request_options: {}) ⇒ Cadenya::Models::Model

Retrieves a model by ID from the workspace

Parameters:

  • id (String)

    Model ID

  • workspace_id (String)

    Workspace ID.

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

Returns:

See Also:



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cadenya/resources/models.rb', line 22

def retrieve(id, params)
  parsed, options = Cadenya::ModelRetrieveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/models/%2$s", workspace_id, id],
    model: Cadenya::Model,
    options: options
  )
end

#set_status(id, workspace_id:, status: nil, request_options: {}) ⇒ Cadenya::Models::Model

Enables or disables a model in the workspace

Parameters:

Returns:

See Also:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/cadenya/resources/models.rb', line 101

def set_status(id, params)
  parsed, options = Cadenya::ModelSetStatusParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["v1/workspaces/%1$s/models/%2$s/status", workspace_id, id],
    body: parsed,
    model: Cadenya::Model,
    options: options
  )
end

#swap(workspace_id, model_swaps: nil, request_options: {}) ⇒ Object

Reassigns agent variations from one model to another in bulk. Runs asynchronously and returns immediately.

Parameters:

Returns:

  • (Object)

See Also:



130
131
132
133
134
135
136
137
138
139
# File 'lib/cadenya/resources/models.rb', line 130

def swap(workspace_id, params = {})
  parsed, options = Cadenya::ModelSwapParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/models:swapModelOnVariations", workspace_id],
    body: parsed,
    model: Cadenya::Internal::Type::Unknown,
    options: options
  )
end