Class: Deeprails::Resources::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/deeprails/resources/monitor.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Monitor

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

Parameters:



173
174
175
# File 'lib/deeprails/resources/monitor.rb', line 173

def initialize(client:)
  @client = client
end

Instance Method Details

#create(guardrail_metrics:, name:, context_awareness: nil, description: nil, file_search: nil, web_search: nil, request_options: {}) ⇒ Deeprails::Models::MonitorCreateResponse

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

Use this endpoint to create a new monitor to evaluate model inputs and outputs using guardrails

Parameters:

  • guardrail_metrics (Array<Symbol, Deeprails::Models::MonitorCreateParams::GuardrailMetric>) —

    An array of guardrail metrics that the model input and output pair will be evalu

  • name (String) —

    Name of the new monitor.

  • context_awareness (Boolean) —

    Context includes any structured information that directly relates to the model’s

  • description (String) —

    Description of the new monitor.

  • file_search (Array<String>) —

    An array of file IDs to search in the monitor's evaluations. Files must be uploa

  • web_search (Boolean) —

    Whether to enable web search for this monitor's evaluations. Defaults to false.

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

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
# File 'lib/deeprails/resources/monitor.rb', line 31

def create(params)
  parsed, options = Deeprails::MonitorCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "monitor",
    body: parsed,
    model: Deeprails::MonitorCreateResponse,
    options: options
  )
end

#retrieve(monitor_id, limit: nil, request_options: {}) ⇒ Deeprails::Models::MonitorDetailResponse

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

Use this endpoint to retrieve the details and evaluations associated with a specific monitor

Parameters:

  • monitor_id (String) —

    The ID of the monitor to retrieve.

  • limit (Integer) —

    Limit the number of returned evaluations associated with this monitor. Defaults

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

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/deeprails/resources/monitor.rb', line 59

def retrieve(monitor_id, params = {})
  parsed, options = Deeprails::MonitorRetrieveParams.dump_request(params)
  query = Deeprails::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["monitor/%1$s", monitor_id],
    query: query,
    model: Deeprails::MonitorDetailResponse,
    options: options
  )
end

#retrieve_event(event_id, monitor_id:, request_options: {}) ⇒ Deeprails::Models::MonitorEventDetailResponse

Use this endpoint to retrieve the details of a specific monitor event

Parameters:

  • event_id (String) —

    The ID of the requested monitor event.

  • monitor_id (String) —

    The ID of the monitor associated with this event.

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

Returns:

See Also:



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/deeprails/resources/monitor.rb', line 122

def retrieve_event(event_id, params)
  parsed, options = Deeprails::MonitorRetrieveEventParams.dump_request(params)
  monitor_id =
    parsed.delete(:monitor_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["monitor/%1$s/events/%2$s", monitor_id, event_id],
    model: Deeprails::MonitorEventDetailResponse,
    options: options
  )
end

#submit_event(monitor_id, model_input:, model_output:, nametag: nil, run_mode: nil, request_options: {}) ⇒ Deeprails::Models::MonitorEventResponse

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

Use this endpoint to submit a model input and output pair to a monitor for evaluation

Parameters:

Returns:

See Also:



159
160
161
162
163
164
165
166
167
168
# File 'lib/deeprails/resources/monitor.rb', line 159

def submit_event(monitor_id, params)
  parsed, options = Deeprails::MonitorSubmitEventParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["monitor/%1$s/events", monitor_id],
    body: parsed,
    model: Deeprails::MonitorEventResponse,
    options: options
  )
end

#update(monitor_id, description: nil, file_search: nil, guardrail_metrics: nil, name: nil, status: nil, web_search: nil, request_options: {}) ⇒ Deeprails::Models::MonitorUpdateResponse

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

Use this endpoint to update the name, status, and/or other details of an existing monitor.

Parameters:

  • monitor_id (String) —

    The ID of the monitor to edit.

  • description (String) —

    New description of the monitor.

  • file_search (Array<String>) —

    An array of file IDs to search in the monitor's evaluations. Files must be uploa

  • guardrail_metrics (Array<Symbol, Deeprails::Models::MonitorUpdateParams::GuardrailMetric>) —

    An array of the new guardrail metrics that model input and output pairs will be

  • name (String) —

    New name of the monitor.

  • status (Symbol, Deeprails::Models::MonitorUpdateParams::Status) —

    Status of the monitor. Can be active or inactive. Inactive monitors no lon

  • web_search (Boolean) —

    Whether to enable web search for this monitor's evaluations.

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

Returns:

See Also:



98
99
100
101
102
103
104
105
106
107
# File 'lib/deeprails/resources/monitor.rb', line 98

def update(monitor_id, params = {})
  parsed, options = Deeprails::MonitorUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["monitor/%1$s", monitor_id],
    body: parsed,
    model: Deeprails::MonitorUpdateResponse,
    options: options
  )
end