Class: Cadenya::Resources::AgentVariations
- Inherits:
-
Object
- Object
- Cadenya::Resources::AgentVariations
- Defined in:
- lib/cadenya/resources/agent_variations.rb
Instance Method Summary collapse
-
#add_assignment(agent_id, variation_id, body:, workspace_id: nil, request_options: nil) ⇒ Object
Add an assignment to a variation.
-
#add_memory_layer(agent_id, variation_id, memory_layer_id:, workspace_id: nil, position: nil, request_options: nil) ⇒ Object
Attach a memory layer to a variation.
-
#create(agent_id, metadata:, spec:, workspace_id: nil, request_options: nil) ⇒ Object
Create a new variation.
-
#delete(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Delete a variation.
-
#initialize(core) ⇒ AgentVariations
constructor
A new instance of AgentVariations.
-
#list(agent_id, workspace_id: nil, limit: nil, cursor: nil, sort_order: nil, include_info: nil, labels: nil, request_options: nil) ⇒ Object
List variations.
-
#remove_assignment(agent_id, variation_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Remove an assignment from a variation.
-
#remove_memory_layer(agent_id, variation_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Remove a memory layer assignment from a variation.
-
#retrieve(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Get a variation by ID.
-
#update(agent_id, id, workspace_id: nil, metadata: nil, spec: nil, update_mask: nil, request_options: nil) ⇒ Object
Update a variation.
-
#update_memory_layer(agent_id, variation_id, id, workspace_id: nil, position: nil, request_options: nil) ⇒ Object
Update a variation's memory layer assignment.
Constructor Details
#initialize(core) ⇒ AgentVariations
Returns a new instance of AgentVariations.
8 9 10 |
# File 'lib/cadenya/resources/agent_variations.rb', line 8 def initialize(core) @core = core end |
Instance Method Details
#add_assignment(agent_id, variation_id, body:, workspace_id: nil, request_options: nil) ⇒ Object
Add an assignment to a variation
73 74 75 76 77 78 |
# File 'lib/cadenya/resources/agent_variations.rb', line 73 def add_assignment(agent_id, variation_id, body:, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('variationId', variation_id)}/assignments" _data = @core.request(:post, _path, body: (->(_v) { Types.encode_AddAgentVariationAssignmentRequest(_v) }).call(body), request_options: ) Types.decode_VariationAssignment(_data) end |
#add_memory_layer(agent_id, variation_id, memory_layer_id:, workspace_id: nil, position: nil, request_options: nil) ⇒ Object
Attach a memory layer to a variation
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cadenya/resources/agent_variations.rb', line 89 def add_memory_layer(agent_id, variation_id, memory_layer_id:, workspace_id: nil, position: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('variationId', variation_id)}/memory_layer_assignments" _body = { "memoryLayerId" => memory_layer_id, "position" => position, }.reject { |_k, v| v.nil? } _data = @core.request(:post, _path, body: _body, request_options: ) Types::VariationMemoryLayerAssignment.from_json(_data) end |
#create(agent_id, metadata:, spec:, workspace_id: nil, request_options: nil) ⇒ Object
Create a new variation
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cadenya/resources/agent_variations.rb', line 32 def create(agent_id, metadata:, spec:, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations" _body = { "metadata" => .nil? ? nil : (->(_v) { Types.encode_CreateResourceMetadata(_v) }).call(), "spec" => spec.nil? ? nil : (->(_v) { Types.encode_AgentVariationSpec(_v) }).call(spec), }.reject { |_k, v| v.nil? } _data = @core.request(:post, _path, body: _body, request_options: ) Types::AgentVariation.from_json(_data) end |
#delete(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Delete a variation
52 53 54 55 56 57 |
# File 'lib/cadenya/resources/agent_variations.rb', line 52 def delete(agent_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('id', id)}" @core.request(:delete, _path, expects_body: false, request_options: ) nil end |
#list(agent_id, workspace_id: nil, limit: nil, cursor: nil, sort_order: nil, include_info: nil, labels: nil, request_options: nil) ⇒ Object
List variations
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cadenya/resources/agent_variations.rb', line 13 def list(agent_id, workspace_id: nil, limit: nil, cursor: nil, sort_order: nil, include_info: nil, labels: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations" _query = { "limit" => limit, "cursor" => cursor, "sortOrder" => sort_order, "includeInfo" => include_info, "labels" => labels, } _data = @core.request(:get, _path, query: _query, request_options: ) || {} _items = (_data["items"] || []).map { |item| Types::AgentVariation.from_json(item) } _next_cursor = (((_data)["pagination"] || {}))["nextCursor"].to_s Page.new(_items, _next_cursor) do |_c| list(agent_id, workspace_id: workspace_id, limit: limit, cursor: _c, sort_order: sort_order, include_info: include_info, labels: labels, request_options: ) end end |
#remove_assignment(agent_id, variation_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Remove an assignment from a variation
81 82 83 84 85 86 |
# File 'lib/cadenya/resources/agent_variations.rb', line 81 def remove_assignment(agent_id, variation_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('variationId', variation_id)}/assignments/#{Util.path_param('id', id)}" @core.request(:delete, _path, expects_body: false, request_options: ) nil end |
#remove_memory_layer(agent_id, variation_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Remove a memory layer assignment from a variation
101 102 103 104 105 106 |
# File 'lib/cadenya/resources/agent_variations.rb', line 101 def remove_memory_layer(agent_id, variation_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('variationId', variation_id)}/memory_layer_assignments/#{Util.path_param('id', id)}" @core.request(:delete, _path, expects_body: false, request_options: ) nil end |
#retrieve(agent_id, id, workspace_id: nil, request_options: nil) ⇒ Object
Get a variation by ID
44 45 46 47 48 49 |
# File 'lib/cadenya/resources/agent_variations.rb', line 44 def retrieve(agent_id, id, workspace_id: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('id', id)}" _data = @core.request(:get, _path, request_options: ) Types::AgentVariation.from_json(_data) end |
#update(agent_id, id, workspace_id: nil, metadata: nil, spec: nil, update_mask: nil, request_options: nil) ⇒ Object
Update a variation
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cadenya/resources/agent_variations.rb', line 60 def update(agent_id, id, workspace_id: nil, metadata: nil, spec: nil, update_mask: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('id', id)}" _body = { "metadata" => .nil? ? nil : (->(_v) { Types.encode_UpdateResourceMetadata(_v) }).call(), "spec" => spec.nil? ? nil : (->(_v) { Types.encode_AgentVariationSpec(_v) }).call(spec), "updateMask" => update_mask, }.reject { |_k, v| v.nil? } _data = @core.request(:patch, _path, body: _body, request_options: ) Types::AgentVariation.from_json(_data) end |
#update_memory_layer(agent_id, variation_id, id, workspace_id: nil, position: nil, request_options: nil) ⇒ Object
Update a variation's memory layer assignment
109 110 111 112 113 114 115 116 117 |
# File 'lib/cadenya/resources/agent_variations.rb', line 109 def update_memory_layer(agent_id, variation_id, id, workspace_id: nil, position: nil, request_options: nil) workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id) _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/agents/#{Util.path_param('agentId', agent_id)}/variations/#{Util.path_param('variationId', variation_id)}/memory_layer_assignments/#{Util.path_param('id', id)}" _body = { "position" => position, }.reject { |_k, v| v.nil? } _data = @core.request(:patch, _path, body: _body, request_options: ) Types::VariationMemoryLayerAssignment.from_json(_data) end |