Class: Cadenya::Resources::Agents::Variations

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

Overview

Manage variations of an agent and their tool, sub-agent, and memory layer assignments.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Variations

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

Parameters:



454
455
456
# File 'lib/cadenya/resources/agents/variations.rb', line 454

def initialize(client:)
  @client = client
end

Instance Method Details

#add_assignment(variation_id, workspace_id:, agent_id:, sub_agent_id: nil, tool_id: nil, tool_set_id: nil, request_options: {}) ⇒ Cadenya::Models::Agents::VariationAssignment

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

Assigns a tool, tool set, or sub-agent to a variation. Exactly one target ID must be set.

Parameters:

  • variation_id (String)

    Path param: Variation ID. Accepts the canonical ‘av_…` form or the `external_id:

  • workspace_id (String)

    Path param: Workspace ID.

  • agent_id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • sub_agent_id (String)

    Body param

  • tool_id (String)

    Body param

  • tool_set_id (String)

    Body param

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

Returns:

See Also:



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/cadenya/resources/agents/variations.rb', line 231

def add_assignment(variation_id, params)
  parsed, options = Cadenya::Agents::VariationAddAssignmentParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: [
      "v1/workspaces/%1$s/agents/%2$s/variations/%3$s/assignments",
      workspace_id,
      agent_id,
      variation_id
    ],
    body: parsed,
    model: Cadenya::Agents::VariationAssignment,
    options: options
  )
end

#add_memory_layer(variation_id, workspace_id:, agent_id:, memory_layer_id: nil, position: nil, request_options: {}) ⇒ Cadenya::Models::Agents::VariationMemoryLayerAssignment

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

Attaches a memory layer to a variation at a given position in the variation’s baseline memory stack.

Parameters:

  • variation_id (String)

    Path param: Variation ID. Accepts the canonical ‘av_…` form or the `external_id:

  • workspace_id (String)

    Path param: Workspace ID.

  • agent_id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • memory_layer_id (String)

    Body param: Layer to attach. Accepts the canonical ‘memlyr_…` form or the `exter

  • position (Integer)

    Body param: Position in the stack. If omitted, server appends

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

Returns:

See Also:



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/cadenya/resources/agents/variations.rb', line 278

def add_memory_layer(variation_id, params)
  parsed, options = Cadenya::Agents::VariationAddMemoryLayerParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: [
      "v1/workspaces/%1$s/agents/%2$s/variations/%3$s/memory_layer_assignments",
      workspace_id,
      agent_id,
      variation_id
    ],
    body: parsed,
    model: Cadenya::Agents::VariationMemoryLayerAssignment,
    options: options
  )
end

#create(agent_id, workspace_id:, metadata:, spec:, request_options: {}) ⇒ Cadenya::Models::Agents::AgentVariation

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

Creates a new variation for an agent

Parameters:

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cadenya/resources/agents/variations.rb', line 29

def create(agent_id, params)
  parsed, options = Cadenya::Agents::VariationCreateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/agents/%2$s/variations", workspace_id, agent_id],
    body: parsed,
    model: Cadenya::Agents::AgentVariation,
    options: options
  )
end

#delete(id, workspace_id:, agent_id:, request_options: {}) ⇒ nil

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

Deletes a variation from an agent

Parameters:

  • id (String)

    Variation ID. Accepts the canonical ‘av_…` form or the `external_id:<value>` for

  • workspace_id (String)

    Workspace ID.

  • agent_id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

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

Returns:

  • (nil)

See Also:



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/cadenya/resources/agents/variations.rb', line 188

def delete(id, params)
  parsed, options = Cadenya::Agents::VariationDeleteParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/workspaces/%1$s/agents/%2$s/variations/%3$s", workspace_id, agent_id, id],
    model: NilClass,
    options: options
  )
end

#list(agent_id, workspace_id:, bundle_key: nil, cursor: nil, include_info: nil, limit: nil, sort_order: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Agents::AgentVariation>

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

Lists all variations for an agent

Parameters:

  • agent_id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • workspace_id (String)

    Path param: Workspace ID.

  • bundle_key (String)

    Query param: Filter by bundle_key — return only resources owned by this bundle.

  • cursor (String)

    Query param: Pagination cursor from previous response

  • include_info (Boolean)

    Query param: When true, the ‘info` field on each returned variation is populated

  • limit (Integer)

    Query param: Maximum number of results to return

  • sort_order (String)

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

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

Returns:

See Also:



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/cadenya/resources/agents/variations.rb', line 149

def list(agent_id, params)
  parsed, options = Cadenya::Agents::VariationListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  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/agents/%2$s/variations", workspace_id, agent_id],
    query: query.transform_keys(
      bundle_key: "bundleKey",
      include_info: "includeInfo",
      sort_order: "sortOrder"
    ),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Agents::AgentVariation,
    options: options
  )
end

#remove_assignment(id, workspace_id:, agent_id:, variation_id:, request_options: {}) ⇒ nil

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

Detaches an assignment from a variation, identified by the assignment ID returned when it was added.

Parameters:

  • id (String)
  • workspace_id (String)

    Workspace ID.

  • agent_id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

  • variation_id (String)

    Variation ID. Accepts the canonical ‘av_…` form or the `external_id:<value>` for

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

Returns:

  • (nil)

See Also:



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/cadenya/resources/agents/variations.rb', line 323

def remove_assignment(id, params)
  parsed, options = Cadenya::Agents::VariationRemoveAssignmentParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  variation_id =
    parsed.delete(:variation_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: [
      "v1/workspaces/%1$s/agents/%2$s/variations/%3$s/assignments/%4$s",
      workspace_id,
      agent_id,
      variation_id,
      id
    ],
    model: NilClass,
    options: options
  )
end

#remove_memory_layer(id, workspace_id:, agent_id:, variation_id:, request_options: {}) ⇒ nil

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

Detaches a memory layer assignment from a variation, identified by the assignment id.

Parameters:

  • id (String)
  • workspace_id (String)

    Workspace ID.

  • agent_id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

  • variation_id (String)

    Variation ID. Accepts the canonical ‘av_…` form or the `external_id:<value>` for

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

Returns:

  • (nil)

See Also:



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/cadenya/resources/agents/variations.rb', line 372

def remove_memory_layer(id, params)
  parsed, options = Cadenya::Agents::VariationRemoveMemoryLayerParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  variation_id =
    parsed.delete(:variation_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: [
      "v1/workspaces/%1$s/agents/%2$s/variations/%3$s/memory_layer_assignments/%4$s",
      workspace_id,
      agent_id,
      variation_id,
      id
    ],
    model: NilClass,
    options: options
  )
end

#retrieve(id, workspace_id:, agent_id:, request_options: {}) ⇒ Cadenya::Models::Agents::AgentVariation

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

Retrieves a variation by ID from an agent

Parameters:

  • id (String)

    Variation ID. Accepts the canonical ‘av_…` form or the `external_id:<value>` for

  • workspace_id (String)

    Workspace ID.

  • agent_id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

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

Returns:

See Also:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cadenya/resources/agents/variations.rb', line 62

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

#update(id, workspace_id:, agent_id:, metadata: nil, spec: nil, update_mask: nil, request_options: {}) ⇒ Cadenya::Models::Agents::AgentVariation

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

Updates a variation for an agent

Parameters:

  • id (String)

    Path param: Variation ID. Accepts the canonical ‘av_…` form or the `external_id:

  • workspace_id (String)

    Path param: Workspace ID.

  • agent_id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • metadata (Cadenya::Models::UpdateResourceMetadata)

    Body param: UpdateResourceMetadata contains the user-provided fields for updatin

  • spec (Cadenya::Models::Agents::AgentVariationSpec)

    Body param: AgentVariationSpec defines the operational configuration for a varia

  • update_mask (String)

    Body param: Fields to update

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

Returns:

See Also:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/cadenya/resources/agents/variations.rb', line 104

def update(id, params)
  parsed, options = Cadenya::Agents::VariationUpdateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["v1/workspaces/%1$s/agents/%2$s/variations/%3$s", workspace_id, agent_id, id],
    body: parsed,
    model: Cadenya::Agents::AgentVariation,
    options: options
  )
end

#update_memory_layer(id, workspace_id:, agent_id:, variation_id:, position: nil, request_options: {}) ⇒ Cadenya::Models::Agents::VariationMemoryLayerAssignment

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

Updates the position of a memory layer assignment on a variation.

Parameters:

  • id (String)

    Path param

  • workspace_id (String)

    Path param: Workspace ID.

  • agent_id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • variation_id (String)

    Path param: Variation ID. Accepts the canonical ‘av_…` form or the `external_id:

  • position (Integer)

    Body param: New position. Only field currently updatable on an assignment.

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

Returns:

See Also:



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/cadenya/resources/agents/variations.rb', line 422

def update_memory_layer(id, params)
  parsed, options = Cadenya::Agents::VariationUpdateMemoryLayerParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  agent_id =
    parsed.delete(:agent_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  variation_id =
    parsed.delete(:variation_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: [
      "v1/workspaces/%1$s/agents/%2$s/variations/%3$s/memory_layer_assignments/%4$s",
      workspace_id,
      agent_id,
      variation_id,
      id
    ],
    body: parsed,
    model: Cadenya::Agents::VariationMemoryLayerAssignment,
    options: options
  )
end