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:



164
165
166
# File 'lib/deeprails/resources/monitor.rb', line 164

def initialize(client:)
  @client = client
end

Instance Method Details

#create(guardrail_metrics:, name:, 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.

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



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

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:



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

def retrieve(monitor_id, params = {})
  parsed, options = Deeprails::MonitorRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["monitor/%1$s", monitor_id],
    query: parsed,
    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:



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/deeprails/resources/monitor.rb', line 113

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:



150
151
152
153
154
155
156
157
158
159
# File 'lib/deeprails/resources/monitor.rb', line 150

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, name: nil, status: 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, description, or status of an existing monitor

Parameters:

  • monitor_id (String)

    The ID of the monitor to edit.

  • description (String)

    Description of the monitor.

  • name (String)

    Name of the monitor.

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

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

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

Returns:

See Also:



89
90
91
92
93
94
95
96
97
98
# File 'lib/deeprails/resources/monitor.rb', line 89

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