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

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

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:



402
403
404
# File 'lib/cadenya/resources/agents/variations.rb', line 402

def initialize(client:)
  @client = client
end

Instance Method Details

#add_assignment(agent_id, variation_id, body:, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::Agents::VariationAssignmentTool, ...

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:

Returns:

See Also:



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/cadenya/resources/agents/variations.rb', line 211

def add_assignment(agent_id, variation_id, params)
  parsed, options = Cadenya::Agents::VariationAddAssignmentParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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[:body],
    model: Cadenya::Agents::VariationAssignment,
    options: options
  )
end

#add_memory_layer(agent_id, variation_id, memory_layer_id:, workspace_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 cascade.

Parameters:

  • 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 agentvar_… form or the `extern

  • memory_layer_id (String)

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

  • workspace_id (String)

    Path param: Workspace ID.

  • position (Integer)

    Body param: Position in the baseline cascade (lower = more specific). If

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

Returns:

See Also:



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/cadenya/resources/agents/variations.rb', line 254

def add_memory_layer(agent_id, variation_id, params)
  parsed, options = Cadenya::Agents::VariationAddMemoryLayerParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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, metadata:, spec:, workspace_id: nil, 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
      @client.workspace_id
    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(agent_id, id, workspace_id: nil, request_options: {}) ⇒ nil

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

Deletes a variation from an agent

Parameters:

  • agent_id (String)

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

  • id (String)

    Variation ID. Accepts the canonical agentvar_… form or the `external_id:<value

  • workspace_id (String)

    Workspace ID.

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

Returns:

  • (nil)

See Also:



176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/cadenya/resources/agents/variations.rb', line 176

def delete(agent_id, id, params = {})
  parsed, options = Cadenya::Agents::VariationDeleteParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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: nil, cursor: nil, include_info: nil, labels: 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.

  • 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

  • labels (String)

    Query param: Filters by metadata labels. Comma-separated key=value pairs,

  • 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:



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/cadenya/resources/agents/variations.rb', line 141

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
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/agents/%2$s/variations", workspace_id, agent_id],
    query: query.transform_keys(include_info: "includeInfo", sort_order: "sortOrder"),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Agents::AgentVariation,
    options: options
  )
end

#remove_assignment(agent_id, variation_id, id, workspace_id: nil, 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:

  • agent_id (String)

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

  • variation_id (String)

    Variation ID. Accepts the canonical agentvar_… form or the `external_id:<value

  • id (String)
  • workspace_id (String)

    Workspace ID.

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

Returns:

  • (nil)

See Also:



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/cadenya/resources/agents/variations.rb', line 295

def remove_assignment(agent_id, variation_id, id, params = {})
  parsed, options = Cadenya::Agents::VariationRemoveAssignmentParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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(agent_id, variation_id, id, workspace_id: nil, 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:

  • agent_id (String)

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

  • variation_id (String)

    Variation ID. Accepts the canonical agentvar_… form or the `external_id:<value

  • id (String)
  • workspace_id (String)

    Workspace ID.

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

Returns:

  • (nil)

See Also:



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/cadenya/resources/agents/variations.rb', line 336

def remove_memory_layer(agent_id, variation_id, id, params = {})
  parsed, options = Cadenya::Agents::VariationRemoveMemoryLayerParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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(agent_id, id, workspace_id: nil, 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:

  • agent_id (String)

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

  • id (String)

    Variation ID. Accepts the canonical agentvar_… form or the `external_id:<value

  • workspace_id (String)

    Workspace ID.

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

Returns:

See Also:



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

def retrieve(agent_id, id, params = {})
  parsed, options = Cadenya::Agents::VariationRetrieveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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(agent_id, id, workspace_id: nil, 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:

  • agent_id (String)

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

  • id (String)

    Path param: Variation ID. Accepts the canonical agentvar_… form or the `extern

  • workspace_id (String)

    Path param: Workspace 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:



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

def update(agent_id, id, params = {})
  parsed, options = Cadenya::Agents::VariationUpdateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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(agent_id, variation_id, id, workspace_id: nil, 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:

  • 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 agentvar_… form or the `extern

  • id (String)

    Path param

  • workspace_id (String)

    Path param: Workspace 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:



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

def update_memory_layer(agent_id, variation_id, id, params = {})
  parsed, options = Cadenya::Agents::VariationUpdateMemoryLayerParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    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