Class: Cadenya::Resources::Objectives
- Inherits:
-
Object
- Object
- Cadenya::Resources::Objectives
- Defined in:
- lib/cadenya/resources/objectives.rb,
lib/cadenya/resources/objectives/tasks.rb,
lib/cadenya/resources/objectives/tools.rb,
lib/cadenya/resources/objectives/feedback.rb,
lib/cadenya/resources/objectives/tool_calls.rb,
sig/cadenya/resources/objectives.rbs,
sig/cadenya/resources/objectives/tasks.rbs,
sig/cadenya/resources/objectives/tools.rbs,
sig/cadenya/resources/objectives/feedback.rbs,
sig/cadenya/resources/objectives/tool_calls.rbs
Defined Under Namespace
Classes: Feedback, Tasks, ToolCalls, Tools
Instance Attribute Summary collapse
- #feedback ⇒ Cadenya::Resources::Objectives::Feedback readonly
- #tasks ⇒ Cadenya::Resources::Objectives::Tasks readonly
- #tool_calls ⇒ Cadenya::Resources::Objectives::ToolCalls readonly
- #tools ⇒ Cadenya::Resources::Objectives::Tools readonly
Instance Method Summary collapse
-
#cancel(objective_id, workspace_id:, reason: nil, request_options: {}) ⇒ Cadenya::Models::Objective
Some parameter documentations has been truncated, see Models::ObjectiveCancelParams for more details.
-
#compact(objective_id, workspace_id:, compaction_config: nil, request_options: {}) ⇒ Cadenya::Models::ObjectiveCompactResponse
Some parameter documentations has been truncated, see Models::ObjectiveCompactParams for more details.
-
#continue(objective_id, workspace_id:, enqueue: nil, message: nil, request_options: {}) ⇒ Cadenya::Models::ObjectiveEvent
Some parameter documentations has been truncated, see Models::ObjectiveContinueParams for more details.
-
#create(workspace_id, agent_id:, system_prompt_data:, episodic_memory: nil, first_user_message: nil, first_user_message_data: nil, memory_cascade: nil, metadata: nil, secrets: nil, variation_id: nil, request_options: {}) ⇒ Cadenya::Models::Objective
Some parameter documentations has been truncated, see Models::ObjectiveCreateParams for more details.
-
#initialize(client:) ⇒ Objectives
constructor
private
A new instance of Objectives.
-
#list(workspace_id, agent_id: nil, agent_schedule_id: nil, cursor: nil, include_info: nil, limit: nil, parent_objective_id: nil, profile_id: nil, sort_order: nil, state: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Objective>
Some parameter documentations has been truncated, see Models::ObjectiveListParams for more details.
-
#list_context_windows(objective_id, workspace_id:, cursor: nil, include_info: nil, limit: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::ObjectiveContextWindow>
Read-only list of the last five windows of execution for this objective, ordered by most recent first.
-
#list_events(objective_id, workspace_id:, cursor: nil, include_info: nil, limit: nil, since_event_id: nil, sort_order: nil, window_id: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::ObjectiveEvent>
Lists all events for an objective.
-
#retrieve(id, workspace_id:, request_options: {}) ⇒ Cadenya::Models::Objective
Retrieves an objective by ID from the workspace.
-
#retrieve_diagnostics(objective_id, workspace_id:, request_options: {}) ⇒ Cadenya::Models::ObjectiveRetrieveDiagnosticsResponse
Returns the context-usage breakdown measured for the objective's most recent iteration: character lengths per context component (system prompt, memory appendices, tool definitions, messages by role) alongside the iteration's input token counts.
-
#stream_events_streaming(objective_id, workspace_id:, request_options: {}) ⇒ Cadenya::Internal::Stream<Cadenya::Models::ObjectiveEvent>
Streams events for an objective in real-time using server-sent events (SSE).
Constructor Details
#initialize(client:) ⇒ Objectives
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 Objectives.
385 386 387 388 389 390 391 |
# File 'lib/cadenya/resources/objectives.rb', line 385 def initialize(client:) @client = client @tools = Cadenya::Resources::Objectives::Tools.new(client: client) @tool_calls = Cadenya::Resources::Objectives::ToolCalls.new(client: client) @tasks = Cadenya::Resources::Objectives::Tasks.new(client: client) @feedback = Cadenya::Resources::Objectives::Feedback.new(client: client) end |
Instance Attribute Details
#feedback ⇒ Cadenya::Resources::Objectives::Feedback (readonly)
16 17 18 |
# File 'lib/cadenya/resources/objectives.rb', line 16 def feedback @feedback end |
#tasks ⇒ Cadenya::Resources::Objectives::Tasks (readonly)
13 14 15 |
# File 'lib/cadenya/resources/objectives.rb', line 13 def tasks @tasks end |
#tool_calls ⇒ Cadenya::Resources::Objectives::ToolCalls (readonly)
10 11 12 |
# File 'lib/cadenya/resources/objectives.rb', line 10 def tool_calls @tool_calls end |
#tools ⇒ Cadenya::Resources::Objectives::Tools (readonly)
7 8 9 |
# File 'lib/cadenya/resources/objectives.rb', line 7 def tools @tools end |
Instance Method Details
#cancel(objective_id, workspace_id:, reason: nil, request_options: {}) ⇒ Cadenya::Models::Objective
Some parameter documentations has been truncated, see Models::ObjectiveCancelParams for more details.
Cancels a running or pending objective. The objective's state will be set to STATE_CANCELLED.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/cadenya/resources/objectives.rb', line 157 def cancel(objective_id, params) parsed, = Cadenya::ObjectiveCancelParams.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/objectives/%2$s:cancel", workspace_id, objective_id], body: parsed, model: Cadenya::Objective, options: ) end |
#compact(objective_id, workspace_id:, compaction_config: nil, request_options: {}) ⇒ Cadenya::Models::ObjectiveCompactResponse
Some parameter documentations has been truncated, see Models::ObjectiveCompactParams for more details.
Triggers compaction on a running objective. Optionally override the variation's compaction config.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/cadenya/resources/objectives.rb', line 191 def compact(objective_id, params) parsed, = Cadenya::ObjectiveCompactParams.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/objectives/%2$s:compact", workspace_id, objective_id], body: parsed, model: Cadenya::Models::ObjectiveCompactResponse, options: ) end |
#continue(objective_id, workspace_id:, enqueue: nil, message: nil, request_options: {}) ⇒ Cadenya::Models::ObjectiveEvent
Some parameter documentations has been truncated, see Models::ObjectiveContinueParams for more details.
Continues an objective that has completed
226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/cadenya/resources/objectives.rb', line 226 def continue(objective_id, params) parsed, = Cadenya::ObjectiveContinueParams.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/objectives/%2$s:continue", workspace_id, objective_id], body: parsed, model: Cadenya::ObjectiveEvent, options: ) end |
#create(workspace_id, agent_id:, system_prompt_data:, episodic_memory: nil, first_user_message: nil, first_user_message_data: nil, memory_cascade: nil, metadata: nil, secrets: nil, variation_id: nil, request_options: {}) ⇒ Cadenya::Models::Objective
Some parameter documentations has been truncated, see Models::ObjectiveCreateParams for more details.
Creates a new objective in the workspace
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cadenya/resources/objectives.rb', line 50 def create(workspace_id, params) parsed, = Cadenya::ObjectiveCreateParams.dump_request(params) @client.request( method: :post, path: ["v1/workspaces/%1$s/objectives", workspace_id], body: parsed, model: Cadenya::Objective, options: ) end |
#list(workspace_id, agent_id: nil, agent_schedule_id: nil, cursor: nil, include_info: nil, limit: nil, parent_objective_id: nil, profile_id: nil, sort_order: nil, state: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Objective>
Some parameter documentations has been truncated, see Models::ObjectiveListParams for more details.
Lists all objectives in the workspace
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cadenya/resources/objectives.rb', line 118 def list(workspace_id, params = {}) parsed, = Cadenya::ObjectiveListParams.dump_request(params) query = Cadenya::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["v1/workspaces/%1$s/objectives", workspace_id], query: query.transform_keys( agent_id: "agentId", agent_schedule_id: "agentScheduleId", include_info: "includeInfo", parent_objective_id: "parentObjectiveId", profile_id: "profileId", sort_order: "sortOrder" ), page: Cadenya::Internal::CursorPagination, model: Cadenya::Objective, options: ) end |
#list_context_windows(objective_id, workspace_id:, cursor: nil, include_info: nil, limit: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::ObjectiveContextWindow>
Read-only list of the last five windows of execution for this objective, ordered by most recent first
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/cadenya/resources/objectives.rb', line 261 def list_context_windows(objective_id, params) parsed, = Cadenya::ObjectiveListContextWindowsParams.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/objectives/%2$s/context_windows", workspace_id, objective_id], query: query.transform_keys(include_info: "includeInfo"), page: Cadenya::Internal::CursorPagination, model: Cadenya::ObjectiveContextWindow, options: ) end |
#list_events(objective_id, workspace_id:, cursor: nil, include_info: nil, limit: nil, since_event_id: nil, sort_order: nil, window_id: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::ObjectiveEvent>
Lists all events for an objective
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/cadenya/resources/objectives.rb', line 303 def list_events(objective_id, params) parsed, = Cadenya::ObjectiveListEventsParams.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/objectives/%2$s/events", workspace_id, objective_id], query: query.transform_keys( include_info: "includeInfo", since_event_id: "sinceEventId", sort_order: "sortOrder", window_id: "windowId" ), page: Cadenya::Internal::CursorPagination, model: Cadenya::ObjectiveEvent, options: ) end |
#retrieve(id, workspace_id:, request_options: {}) ⇒ Cadenya::Models::Objective
Retrieves an objective by ID from the workspace
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cadenya/resources/objectives.rb', line 72 def retrieve(id, params) parsed, = Cadenya::ObjectiveRetrieveParams.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/objectives/%2$s", workspace_id, id], model: Cadenya::Objective, options: ) end |
#retrieve_diagnostics(objective_id, workspace_id:, request_options: {}) ⇒ Cadenya::Models::ObjectiveRetrieveDiagnosticsResponse
Returns the context-usage breakdown measured for the objective's most recent iteration: character lengths per context component (system prompt, memory appendices, tool definitions, messages by role) alongside the iteration's input token counts.
341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/cadenya/resources/objectives.rb', line 341 def retrieve_diagnostics(objective_id, params) parsed, = Cadenya::ObjectiveRetrieveDiagnosticsParams.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/objectives/%2$s/diagnostics", workspace_id, objective_id], model: Cadenya::Models::ObjectiveRetrieveDiagnosticsResponse, options: ) end |
#stream_events_streaming(objective_id, workspace_id:, request_options: {}) ⇒ Cadenya::Internal::Stream<Cadenya::Models::ObjectiveEvent>
Streams events for an objective in real-time using server-sent events (SSE)
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/cadenya/resources/objectives.rb', line 366 def stream_events_streaming(objective_id, params) parsed, = Cadenya::ObjectiveStreamEventsParams.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/objectives/%2$s/events:stream", workspace_id, objective_id], headers: {"accept" => "text/event-stream", "accept-encoding" => "identity"}, stream: Cadenya::Internal::Stream, model: Cadenya::ObjectiveEvent, options: ) end |