Documentation
¶
Index ¶
- func Bool(value bool) param.Field[bool]
- func DefaultClientOptions() []option.RequestOption
- func F[T any](value T) param.Field[T]
- func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]
- func Float(value float64) param.Field[float64]
- func Int(value int64) param.Field[int64]
- func Null[T any]() param.Field[T]
- func Raw[T any](value any) param.Field[T]
- func String(value string) param.Field[string]
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, ...) error
- func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- type DefendCreateResponse
- type DefendCreateResponseStatus
- type DefendGetWorkflowParams
- type DefendNewWorkflowParams
- type DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels
- type DefendNewWorkflowParamsImprovementAction
- type DefendNewWorkflowParamsThresholdType
- type DefendResponse
- type DefendResponseAutomaticHallucinationToleranceLevel
- type DefendResponseCapability
- type DefendResponseEvent
- type DefendResponseEventsEvaluation
- type DefendResponseEventsEvaluationsImprovementToolStatus
- type DefendResponseEventsImprovementToolStatus
- type DefendResponseEventsStatus
- type DefendResponseFile
- type DefendResponseImprovementAction
- type DefendResponseStats
- type DefendResponseStatus
- type DefendResponseThresholdType
- type DefendService
- func (r *DefendService) GetEvent(ctx context.Context, workflowID string, eventID string, ...) (res *WorkflowEventDetailResponse, err error)
- func (r *DefendService) GetWorkflow(ctx context.Context, workflowID string, query DefendGetWorkflowParams, ...) (res *DefendResponse, err error)
- func (r *DefendService) NewWorkflow(ctx context.Context, body DefendNewWorkflowParams, ...) (res *DefendCreateResponse, err error)
- func (r *DefendService) SubmitAndStreamEventStreaming(ctx context.Context, workflowID string, ...) (stream *ssestream.Stream[string])
- func (r *DefendService) SubmitEvent(ctx context.Context, workflowID string, body DefendSubmitEventParams, ...) (res *WorkflowEventResponse, err error)
- func (r *DefendService) UpdateWorkflow(ctx context.Context, workflowID string, body DefendUpdateWorkflowParams, ...) (res *DefendUpdateResponse, err error)
- type DefendSubmitAndStreamEventParams
- type DefendSubmitAndStreamEventParamsRunMode
- type DefendSubmitEventParams
- type DefendSubmitEventParamsModelInput
- type DefendSubmitEventParamsModelInputContext
- type DefendSubmitEventParamsRunMode
- type DefendUpdateResponse
- type DefendUpdateResponseStatus
- type DefendUpdateWorkflowParams
- type DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels
- type DefendUpdateWorkflowParamsImprovementAction
- type DefendUpdateWorkflowParamsThresholdType
- type Error
- type FileResponse
- type FileService
- type FileUploadParams
- type MonitorCreateResponse
- type MonitorCreateResponseStatus
- type MonitorDetailResponse
- type MonitorDetailResponseCapability
- type MonitorDetailResponseEvaluation
- type MonitorDetailResponseEvaluationsEvaluationStatus
- type MonitorDetailResponseEvaluationsGuardrailMetric
- type MonitorDetailResponseEvaluationsModelInput
- type MonitorDetailResponseEvaluationsModelInputContext
- type MonitorDetailResponseEvaluationsRunMode
- type MonitorDetailResponseFile
- type MonitorDetailResponseStats
- type MonitorDetailResponseStatus
- type MonitorEventDetailResponse
- type MonitorEventDetailResponseCapability
- type MonitorEventDetailResponseFile
- type MonitorEventDetailResponseRunMode
- type MonitorEventDetailResponseStatus
- type MonitorEventResponse
- type MonitorGetParams
- type MonitorNewParams
- type MonitorNewParamsGuardrailMetric
- type MonitorService
- func (r *MonitorService) Get(ctx context.Context, monitorID string, query MonitorGetParams, ...) (res *MonitorDetailResponse, err error)
- func (r *MonitorService) GetEvent(ctx context.Context, monitorID string, eventID string, ...) (res *MonitorEventDetailResponse, err error)
- func (r *MonitorService) New(ctx context.Context, body MonitorNewParams, opts ...option.RequestOption) (res *MonitorCreateResponse, err error)
- func (r *MonitorService) SubmitEvent(ctx context.Context, monitorID string, body MonitorSubmitEventParams, ...) (res *MonitorEventResponse, err error)
- func (r *MonitorService) Update(ctx context.Context, monitorID string, body MonitorUpdateParams, ...) (res *MonitorUpdateResponse, err error)
- type MonitorSubmitEventParams
- type MonitorSubmitEventParamsModelInput
- type MonitorSubmitEventParamsModelInputContext
- type MonitorSubmitEventParamsRunMode
- type MonitorUpdateParams
- type MonitorUpdateParamsGuardrailMetric
- type MonitorUpdateParamsStatus
- type MonitorUpdateResponse
- type MonitorUpdateResponseStatus
- type WorkflowEventDetailResponse
- type WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel
- type WorkflowEventDetailResponseCapability
- type WorkflowEventDetailResponseEvaluationHistory
- type WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus
- type WorkflowEventDetailResponseFile
- type WorkflowEventDetailResponseImprovementAction
- type WorkflowEventDetailResponseImprovementToolStatus
- type WorkflowEventDetailResponseKeyImprovement
- type WorkflowEventDetailResponseStatus
- type WorkflowEventDetailResponseThresholdType
- type WorkflowEventResponse
- type WorkflowEventResponseStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment (DEEPRAILS_API_KEY, DEEP_RAILS_BASE_URL). This should be used to initialize new clients.
func F ¶ added in v0.2.0
F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.
func FileParam ¶ added in v0.2.0
FileParam is a param field helper which helps files with a mime content-type.
func Int ¶
Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.
func Raw ¶ added in v0.2.0
Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).
Types ¶
type Client ¶
type Client struct {
Options []option.RequestOption
Defend *DefendService
Monitor *MonitorService
Files *FileService
}
Client creates a struct with services and top level methods that help with interacting with the deep rails API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r *Client)
NewClient generates a new client with the default option read from the environment (DEEPRAILS_API_KEY, DEEP_RAILS_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Post ¶
func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type DefendCreateResponse ¶ added in v0.12.0
type DefendCreateResponse struct {
// The time the workflow was created in UTC.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// Status of the selected workflow. May be `inactive` or `active`. Inactive
// workflows will not accept events.
Status DefendCreateResponseStatus `json:"status" api:"required"`
// A unique workflow ID.
WorkflowID string `json:"workflow_id" api:"required"`
JSON defendCreateResponseJSON `json:"-"`
}
func (*DefendCreateResponse) UnmarshalJSON ¶ added in v0.12.0
func (r *DefendCreateResponse) UnmarshalJSON(data []byte) (err error)
type DefendCreateResponseStatus ¶ added in v0.12.0
type DefendCreateResponseStatus string
Status of the selected workflow. May be `inactive` or `active`. Inactive workflows will not accept events.
const ( DefendCreateResponseStatusInactive DefendCreateResponseStatus = "inactive" DefendCreateResponseStatusActive DefendCreateResponseStatus = "active" )
func (DefendCreateResponseStatus) IsKnown ¶ added in v0.12.0
func (r DefendCreateResponseStatus) IsKnown() bool
type DefendGetWorkflowParams ¶ added in v0.12.0
type DefendGetWorkflowParams struct {
// Limit the number of returned events associated with this workflow. Defaults
// to 10.
Limit param.Field[int64] `query:"limit"`
}
func (DefendGetWorkflowParams) URLQuery ¶ added in v0.12.0
func (r DefendGetWorkflowParams) URLQuery() (v url.Values)
URLQuery serializes DefendGetWorkflowParams's query parameters as `url.Values`.
type DefendNewWorkflowParams ¶
type DefendNewWorkflowParams struct {
// The action used to improve outputs that fail one or more guardrail metrics for
// the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the
// user's input prompt with minor induced variance. FixIt attempts to directly
// address the shortcomings of the output using the guardrail failure rationale. Do
// Nothing does not attempt any improvement.
ImprovementAction param.Field[DefendNewWorkflowParamsImprovementAction] `json:"improvement_action" api:"required"`
// Name of the workflow.
Name param.Field[string] `json:"name" api:"required"`
// Type of thresholds to use for the workflow, either `automatic` or `custom`.
// Automatic thresholds are assigned internally after the user specifies a
// qualitative tolerance for the metrics, whereas custom metrics allow the user to
// set the threshold for each metric as a floating point number between 0.0 and
// 1.0.
ThresholdType param.Field[DefendNewWorkflowParamsThresholdType] `json:"threshold_type" api:"required"`
// Mapping of guardrail metrics to hallucination tolerance levels (either `low`,
// `medium`, or `high`). Possible metrics are `completeness`,
// `instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
// `comprehensive_safety`.
AutomaticHallucinationToleranceLevels param.Field[map[string]DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels] `json:"automatic_hallucination_tolerance_levels"`
// Context includes any structured information that directly relates to the model’s
// input and expected output—e.g., the recent turn-by-turn history between an AI
// tutor and a student, facts or state passed through an agentic workflow, or other
// domain-specific signals your system already knows and wants the model to
// condition on. This field determines whether to enable context awareness for this
// workflow's evaluations. Defaults to false.
ContextAwareness param.Field[bool] `json:"context_awareness"`
// Mapping of guardrail metrics to floating point threshold values. Possible
// metrics are `correctness`, `completeness`, `instruction_adherence`,
// `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
CustomHallucinationThresholdValues param.Field[map[string]float64] `json:"custom_hallucination_threshold_values"`
// Description for the workflow.
Description param.Field[string] `json:"description"`
// An array of file IDs to search in the workflow's evaluations. Files must be
// uploaded via the DeepRails API first.
FileSearch param.Field[[]string] `json:"file_search"`
// Max. number of improvement action attempts until a given event passes the
// guardrails. Defaults to 10.
MaxImprovementAttempts param.Field[int64] `json:"max_improvement_attempts"`
// Whether to enable web search for this workflow's evaluations. Defaults to false.
WebSearch param.Field[bool] `json:"web_search"`
}
func (DefendNewWorkflowParams) MarshalJSON ¶
func (r DefendNewWorkflowParams) MarshalJSON() (data []byte, err error)
type DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels ¶ added in v0.6.0
type DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels string
const ( DefendNewWorkflowParamsAutomaticHallucinationToleranceLevelsLow DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels = "low" DefendNewWorkflowParamsAutomaticHallucinationToleranceLevelsMedium DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels = "medium" DefendNewWorkflowParamsAutomaticHallucinationToleranceLevelsHigh DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels = "high" )
func (DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels) IsKnown ¶ added in v0.6.0
func (r DefendNewWorkflowParamsAutomaticHallucinationToleranceLevels) IsKnown() bool
type DefendNewWorkflowParamsImprovementAction ¶
type DefendNewWorkflowParamsImprovementAction string
The action used to improve outputs that fail one or more guardrail metrics for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the user's input prompt with minor induced variance. FixIt attempts to directly address the shortcomings of the output using the guardrail failure rationale. Do Nothing does not attempt any improvement.
const ( DefendNewWorkflowParamsImprovementActionRegen DefendNewWorkflowParamsImprovementAction = "regen" DefendNewWorkflowParamsImprovementActionFixit DefendNewWorkflowParamsImprovementAction = "fixit" DefendNewWorkflowParamsImprovementActionDoNothing DefendNewWorkflowParamsImprovementAction = "do_nothing" )
func (DefendNewWorkflowParamsImprovementAction) IsKnown ¶ added in v0.2.0
func (r DefendNewWorkflowParamsImprovementAction) IsKnown() bool
type DefendNewWorkflowParamsThresholdType ¶ added in v0.12.0
type DefendNewWorkflowParamsThresholdType string
Type of thresholds to use for the workflow, either `automatic` or `custom`. Automatic thresholds are assigned internally after the user specifies a qualitative tolerance for the metrics, whereas custom metrics allow the user to set the threshold for each metric as a floating point number between 0.0 and 1.0.
const ( DefendNewWorkflowParamsThresholdTypeAutomatic DefendNewWorkflowParamsThresholdType = "automatic" DefendNewWorkflowParamsThresholdTypeCustom DefendNewWorkflowParamsThresholdType = "custom" )
func (DefendNewWorkflowParamsThresholdType) IsKnown ¶ added in v0.12.0
func (r DefendNewWorkflowParamsThresholdType) IsKnown() bool
type DefendResponse ¶
type DefendResponse struct {
// Mapping of guardrail metric names to tolerance values. Values can be strings
// (`low`, `medium`, `high`) for automatic tolerance levels.
AutomaticHallucinationToleranceLevels map[string]DefendResponseAutomaticHallucinationToleranceLevel `json:"automatic_hallucination_tolerance_levels" api:"required"`
// Extended AI capabilities available to the event, if any. Can be `web_search`,
// `file_search`, and/or `context_awareness`.
Capabilities []DefendResponseCapability `json:"capabilities" api:"required"`
// The time the workflow was created in UTC.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// Mapping of guardrail metric names to threshold values. Values can be floating
// point numbers (0.0-1.0) for custom thresholds.
CustomHallucinationThresholdValues map[string]float64 `json:"custom_hallucination_threshold_values" api:"required"`
// A description for the workflow, to help you remember what that workflow means to
// your organization.
Description string `json:"description" api:"required"`
// An array of events associated with this workflow.
Events []DefendResponseEvent `json:"events" api:"required"`
// List of files associated with the workflow. If this is not empty, models can
// search these files when performing evaluations or remediations
Files []DefendResponseFile `json:"files" api:"required"`
// A human-readable name for the workflow that will correspond to it's workflow ID.
Name string `json:"name" api:"required"`
// Status of the selected workflow. May be `inactive` or `active`. Inactive
// workflows will not accept events.
Status DefendResponseStatus `json:"status" api:"required"`
// Type of thresholds used to evaluate the event.
ThresholdType DefendResponseThresholdType `json:"threshold_type" api:"required"`
// The most recent time the workflow was updated in UTC.
UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"`
// A unique workflow ID used to identify the workflow in other endpoints.
WorkflowID string `json:"workflow_id" api:"required"`
// The action used to improve outputs that fail one or more guardrail metrics for
// the workflow events.
ImprovementAction DefendResponseImprovementAction `json:"improvement_action"`
Stats DefendResponseStats `json:"stats"`
JSON defendResponseJSON `json:"-"`
}
func (*DefendResponse) UnmarshalJSON ¶
func (r *DefendResponse) UnmarshalJSON(data []byte) (err error)
type DefendResponseAutomaticHallucinationToleranceLevel ¶ added in v0.12.0
type DefendResponseAutomaticHallucinationToleranceLevel string
const ( DefendResponseAutomaticHallucinationToleranceLevelLow DefendResponseAutomaticHallucinationToleranceLevel = "low" DefendResponseAutomaticHallucinationToleranceLevelMedium DefendResponseAutomaticHallucinationToleranceLevel = "medium" DefendResponseAutomaticHallucinationToleranceLevelHigh DefendResponseAutomaticHallucinationToleranceLevel = "high" )
func (DefendResponseAutomaticHallucinationToleranceLevel) IsKnown ¶ added in v0.12.0
func (r DefendResponseAutomaticHallucinationToleranceLevel) IsKnown() bool
type DefendResponseCapability ¶ added in v0.12.0
type DefendResponseCapability struct {
Capability string `json:"capability"`
JSON defendResponseCapabilityJSON `json:"-"`
}
func (*DefendResponseCapability) UnmarshalJSON ¶ added in v0.12.0
func (r *DefendResponseCapability) UnmarshalJSON(data []byte) (err error)
type DefendResponseEvent ¶ added in v0.12.0
type DefendResponseEvent struct {
// The ID of the billing request for the event.
BillingRequestID string `json:"billing_request_id"`
// An array of evaluations for this event.
Evaluations []DefendResponseEventsEvaluation `json:"evaluations"`
// A unique workflow event ID.
EventID string `json:"event_id"`
// Improved model output after improvement tool was applied.
ImprovedModelOutput string `json:"improved_model_output"`
// Status of the improvement tool used to improve the event. `improvement_required`
// indicates that the evaluation is complete and the improvement action is needed
// but is not taking place. `improved` and `improvement_failed` indicate when the
// improvement action concludes, successfully and unsuccessfully, respectively.
// `no_improvement_required` means that the first evaluation passed all its
// metrics!
ImprovementToolStatus DefendResponseEventsImprovementToolStatus `json:"improvement_tool_status"`
// Status of the event.
Status DefendResponseEventsStatus `json:"status"`
JSON defendResponseEventJSON `json:"-"`
}
func (*DefendResponseEvent) UnmarshalJSON ¶ added in v0.12.0
func (r *DefendResponseEvent) UnmarshalJSON(data []byte) (err error)
type DefendResponseEventsEvaluation ¶ added in v0.12.0
type DefendResponseEventsEvaluation struct {
// Analysis of the failures of the model_output according to the guardrail metrics
// evaluated.
AnalysisOfFailures string `json:"analysis_of_failures"`
// The attempt number or identifier for this evaluation.
Attempt string `json:"attempt"`
// The time the evaluation was created in UTC.
CreatedAt time.Time `json:"created_at" format:"date-time"`
// Error message if the evaluation failed.
ErrorMessage string `json:"error_message"`
// The result of the evaluation.
EvaluationResult map[string]interface{} `json:"evaluation_result"`
// Status of the evaluation.
EvaluationStatus string `json:"evaluation_status"`
// Total cost of the evaluation.
EvaluationTotalCost float64 `json:"evaluation_total_cost"`
// An array of guardrail metrics evaluated.
GuardrailMetrics []string `json:"guardrail_metrics"`
// Status of the improvement tool used to improve the event. `improvement_required`
// indicates that the evaluation is complete and the improvement action is needed
// but is not taking place. `improved` and `improvement_failed` indicate when the
// improvement action concludes, successfully and unsuccessfully, respectively.
// `no_improvement_required` means that the first evaluation passed all its
// metrics!
ImprovementToolStatus DefendResponseEventsEvaluationsImprovementToolStatus `json:"improvement_tool_status"`
// A list of key improvements made to the model_output to address the failures.
KeyImprovements []string `json:"key_improvements"`
// The model input used for the evaluation.
ModelInput map[string]interface{} `json:"model_input"`
// The model output that was evaluated.
ModelOutput string `json:"model_output"`
// The time the evaluation was last modified in UTC.
ModifiedAt time.Time `json:"modified_at" format:"date-time"`
// An optional tag for the evaluation.
Nametag string `json:"nametag"`
// Evaluation progress (0-100).
Progress int64 `json:"progress"`
// Run mode used for the evaluation.
RunMode string `json:"run_mode"`
JSON defendResponseEventsEvaluationJSON `json:"-"`
}
func (*DefendResponseEventsEvaluation) UnmarshalJSON ¶ added in v0.12.0
func (r *DefendResponseEventsEvaluation) UnmarshalJSON(data []byte) (err error)
type DefendResponseEventsEvaluationsImprovementToolStatus ¶ added in v0.22.0
type DefendResponseEventsEvaluationsImprovementToolStatus string
Status of the improvement tool used to improve the event. `improvement_required` indicates that the evaluation is complete and the improvement action is needed but is not taking place. `improved` and `improvement_failed` indicate when the improvement action concludes, successfully and unsuccessfully, respectively. `no_improvement_required` means that the first evaluation passed all its metrics!
const ( DefendResponseEventsEvaluationsImprovementToolStatusImproved DefendResponseEventsEvaluationsImprovementToolStatus = "improved" DefendResponseEventsEvaluationsImprovementToolStatusImprovementFailed DefendResponseEventsEvaluationsImprovementToolStatus = "improvement_failed" DefendResponseEventsEvaluationsImprovementToolStatusNoImprovementRequired DefendResponseEventsEvaluationsImprovementToolStatus = "no_improvement_required" DefendResponseEventsEvaluationsImprovementToolStatusImprovementRequired DefendResponseEventsEvaluationsImprovementToolStatus = "improvement_required" )
func (DefendResponseEventsEvaluationsImprovementToolStatus) IsKnown ¶ added in v0.22.0
func (r DefendResponseEventsEvaluationsImprovementToolStatus) IsKnown() bool
type DefendResponseEventsImprovementToolStatus ¶ added in v0.21.0
type DefendResponseEventsImprovementToolStatus string
Status of the improvement tool used to improve the event. `improvement_required` indicates that the evaluation is complete and the improvement action is needed but is not taking place. `improved` and `improvement_failed` indicate when the improvement action concludes, successfully and unsuccessfully, respectively. `no_improvement_required` means that the first evaluation passed all its metrics!
const ( DefendResponseEventsImprovementToolStatusImproved DefendResponseEventsImprovementToolStatus = "improved" DefendResponseEventsImprovementToolStatusImprovementFailed DefendResponseEventsImprovementToolStatus = "improvement_failed" DefendResponseEventsImprovementToolStatusNoImprovementRequired DefendResponseEventsImprovementToolStatus = "no_improvement_required" DefendResponseEventsImprovementToolStatusImprovementRequired DefendResponseEventsImprovementToolStatus = "improvement_required" )
func (DefendResponseEventsImprovementToolStatus) IsKnown ¶ added in v0.21.0
func (r DefendResponseEventsImprovementToolStatus) IsKnown() bool
type DefendResponseEventsStatus ¶ added in v0.22.0
type DefendResponseEventsStatus string
Status of the event.
const ( DefendResponseEventsStatusCompleted DefendResponseEventsStatus = "completed" DefendResponseEventsStatusFailed DefendResponseEventsStatus = "failed" DefendResponseEventsStatusInProgress DefendResponseEventsStatus = "in_progress" )
func (DefendResponseEventsStatus) IsKnown ¶ added in v0.22.0
func (r DefendResponseEventsStatus) IsKnown() bool
type DefendResponseFile ¶ added in v0.12.0
type DefendResponseFile struct {
FileID string `json:"file_id"`
FileName string `json:"file_name"`
FileSize int64 `json:"file_size"`
PresignedURL string `json:"presigned_url"`
PresignedURLExpiresAt time.Time `json:"presigned_url_expires_at" format:"date-time"`
JSON defendResponseFileJSON `json:"-"`
}
func (*DefendResponseFile) UnmarshalJSON ¶ added in v0.12.0
func (r *DefendResponseFile) UnmarshalJSON(data []byte) (err error)
type DefendResponseImprovementAction ¶
type DefendResponseImprovementAction string
The action used to improve outputs that fail one or more guardrail metrics for the workflow events.
const ( DefendResponseImprovementActionRegen DefendResponseImprovementAction = "regen" DefendResponseImprovementActionFixit DefendResponseImprovementAction = "fixit" DefendResponseImprovementActionDoNothing DefendResponseImprovementAction = "do_nothing" )
func (DefendResponseImprovementAction) IsKnown ¶ added in v0.2.0
func (r DefendResponseImprovementAction) IsKnown() bool
type DefendResponseStats ¶ added in v0.12.0
type DefendResponseStats struct {
// Number of AI outputs that failed the guardrails.
OutputsBelowThreshold int64 `json:"outputs_below_threshold"`
// Number of AI outputs that were improved.
OutputsImproved int64 `json:"outputs_improved"`
// Total number of AI outputs processed by the workflow.
OutputsProcessed int64 `json:"outputs_processed"`
JSON defendResponseStatsJSON `json:"-"`
}
func (*DefendResponseStats) UnmarshalJSON ¶ added in v0.12.0
func (r *DefendResponseStats) UnmarshalJSON(data []byte) (err error)
type DefendResponseStatus ¶
type DefendResponseStatus string
Status of the selected workflow. May be `inactive` or `active`. Inactive workflows will not accept events.
const ( DefendResponseStatusInactive DefendResponseStatus = "inactive" DefendResponseStatusActive DefendResponseStatus = "active" )
func (DefendResponseStatus) IsKnown ¶ added in v0.2.0
func (r DefendResponseStatus) IsKnown() bool
type DefendResponseThresholdType ¶ added in v0.12.0
type DefendResponseThresholdType string
Type of thresholds used to evaluate the event.
const ( DefendResponseThresholdTypeCustom DefendResponseThresholdType = "custom" DefendResponseThresholdTypeAutomatic DefendResponseThresholdType = "automatic" )
func (DefendResponseThresholdType) IsKnown ¶ added in v0.12.0
func (r DefendResponseThresholdType) IsKnown() bool
type DefendService ¶
type DefendService struct {
Options []option.RequestOption
}
DefendService contains methods and other services that help with interacting with the deep rails API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewDefendService method instead.
func NewDefendService ¶
func NewDefendService(opts ...option.RequestOption) (r *DefendService)
NewDefendService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*DefendService) GetEvent ¶
func (r *DefendService) GetEvent(ctx context.Context, workflowID string, eventID string, opts ...option.RequestOption) (res *WorkflowEventDetailResponse, err error)
Use this endpoint to retrieve a specific event of a guardrail workflow
func (*DefendService) GetWorkflow ¶
func (r *DefendService) GetWorkflow(ctx context.Context, workflowID string, query DefendGetWorkflowParams, opts ...option.RequestOption) (res *DefendResponse, err error)
Use this endpoint to retrieve the details for a specific defend workflow
func (*DefendService) NewWorkflow ¶
func (r *DefendService) NewWorkflow(ctx context.Context, body DefendNewWorkflowParams, opts ...option.RequestOption) (res *DefendCreateResponse, err error)
Use this endpoint to create a new guardrail workflow by specifying guardrail thresholds, an improvement action, and optional extended capabilities.
func (*DefendService) SubmitAndStreamEventStreaming ¶ added in v0.23.0
func (r *DefendService) SubmitAndStreamEventStreaming(ctx context.Context, workflowID string, params DefendSubmitAndStreamEventParams, opts ...option.RequestOption) (stream *ssestream.Stream[string])
Use this endpoint to submit a model input and output pair to a workflow for evaluation with streaming responses.
func (*DefendService) SubmitEvent ¶
func (r *DefendService) SubmitEvent(ctx context.Context, workflowID string, body DefendSubmitEventParams, opts ...option.RequestOption) (res *WorkflowEventResponse, err error)
Use this endpoint to submit a model input and output pair to a workflow for evaluation
func (*DefendService) UpdateWorkflow ¶
func (r *DefendService) UpdateWorkflow(ctx context.Context, workflowID string, body DefendUpdateWorkflowParams, opts ...option.RequestOption) (res *DefendUpdateResponse, err error)
Use this endpoint to update an existing defend workflow if its details change.
type DefendSubmitAndStreamEventParams ¶ added in v0.23.0
type DefendSubmitAndStreamEventParams struct {
// The input provided to the model (e.g., prompt, messages).
ModelInput param.Field[map[string]interface{}] `json:"model_input" api:"required"`
// The output generated by the model to be evaluated.
ModelOutput param.Field[string] `json:"model_output" api:"required"`
// The model that generated the output (e.g., "gpt-4", "claude-3").
ModelUsed param.Field[string] `json:"model_used" api:"required"`
// The evaluation run mode. Streaming is supported on all run modes except
// precision_max and precision_max_codex. Note: super_fast does not support Web
// Search or File Search — if your workflow has these enabled, use a different run
// mode or disable the capability on the workflow.
RunMode param.Field[DefendSubmitAndStreamEventParamsRunMode] `json:"run_mode" api:"required"`
// Enable SSE streaming for real-time token feedback. Supported on all run modes
// except precision_max and precision_max_codex.
Stream param.Field[bool] `query:"stream"`
// Optional tag to identify this event.
Nametag param.Field[string] `json:"nametag"`
}
func (DefendSubmitAndStreamEventParams) MarshalJSON ¶ added in v0.23.0
func (r DefendSubmitAndStreamEventParams) MarshalJSON() (data []byte, err error)
func (DefendSubmitAndStreamEventParams) URLQuery ¶ added in v0.23.0
func (r DefendSubmitAndStreamEventParams) URLQuery() (v url.Values)
URLQuery serializes DefendSubmitAndStreamEventParams's query parameters as `url.Values`.
type DefendSubmitAndStreamEventParamsRunMode ¶ added in v0.23.0
type DefendSubmitAndStreamEventParamsRunMode string
The evaluation run mode. Streaming is supported on all run modes except precision_max and precision_max_codex. Note: super_fast does not support Web Search or File Search — if your workflow has these enabled, use a different run mode or disable the capability on the workflow.
const ( DefendSubmitAndStreamEventParamsRunModeSuperFast DefendSubmitAndStreamEventParamsRunMode = "super_fast" DefendSubmitAndStreamEventParamsRunModeFast DefendSubmitAndStreamEventParamsRunMode = "fast" DefendSubmitAndStreamEventParamsRunModePrecision DefendSubmitAndStreamEventParamsRunMode = "precision" DefendSubmitAndStreamEventParamsRunModePrecisionCodex DefendSubmitAndStreamEventParamsRunMode = "precision_codex" )
func (DefendSubmitAndStreamEventParamsRunMode) IsKnown ¶ added in v0.23.0
func (r DefendSubmitAndStreamEventParamsRunMode) IsKnown() bool
type DefendSubmitEventParams ¶
type DefendSubmitEventParams struct {
// A dictionary of inputs sent to the LLM to generate output. The dictionary must
// contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
// `ground_truth` should be provided.
ModelInput param.Field[DefendSubmitEventParamsModelInput] `json:"model_input" api:"required"`
// Output generated by the LLM to be evaluated.
ModelOutput param.Field[string] `json:"model_output" api:"required"`
// Model ID used to generate the output, like `gpt-4o` or `o3`.
ModelUsed param.Field[string] `json:"model_used" api:"required"`
// Run mode for the workflow event. The run mode allows the user to optimize for
// speed, accuracy, and cost by determining which models are used to evaluate the
// event. Available run modes (fastest to most thorough): `super_fast`, `fast`,
// `precision`, `precision_codex`, `precision_max`, and `precision_max_codex`.
// Defaults to `fast`. Note: `super_fast` does not support Web Search or File
// Search — if your workflow has these capabilities enabled, use a different run
// mode or edit the workflow to disable them.
RunMode param.Field[DefendSubmitEventParamsRunMode] `json:"run_mode" api:"required"`
// An optional, user-defined tag for the event.
Nametag param.Field[string] `json:"nametag"`
}
func (DefendSubmitEventParams) MarshalJSON ¶
func (r DefendSubmitEventParams) MarshalJSON() (data []byte, err error)
type DefendSubmitEventParamsModelInput ¶
type DefendSubmitEventParamsModelInput struct {
// The user prompt used to generate the output.
UserPrompt param.Field[string] `json:"user_prompt" api:"required"`
// Any structured information that directly relates to the model’s input and
// expected output—e.g., the recent turn-by-turn history between an AI tutor and a
// student, facts or state passed through an agentic workflow, or other
// domain-specific signals your system already knows and wants the model to
// condition on.
Context param.Field[[]DefendSubmitEventParamsModelInputContext] `json:"context"`
// The ground truth for evaluating the Ground Truth Adherence guardrail.
GroundTruth param.Field[string] `json:"ground_truth"`
// The system prompt used to generate the output.
SystemPrompt param.Field[string] `json:"system_prompt"`
}
A dictionary of inputs sent to the LLM to generate output. The dictionary must contain a `user_prompt` field. For the ground_truth_adherence guardrail metric, `ground_truth` should be provided.
func (DefendSubmitEventParamsModelInput) MarshalJSON ¶
func (r DefendSubmitEventParamsModelInput) MarshalJSON() (data []byte, err error)
type DefendSubmitEventParamsModelInputContext ¶ added in v0.22.0
type DefendSubmitEventParamsModelInputContext struct {
// The content of the message.
Content param.Field[string] `json:"content"`
// The role of the speaker.
Role param.Field[string] `json:"role"`
}
func (DefendSubmitEventParamsModelInputContext) MarshalJSON ¶ added in v0.22.0
func (r DefendSubmitEventParamsModelInputContext) MarshalJSON() (data []byte, err error)
type DefendSubmitEventParamsRunMode ¶
type DefendSubmitEventParamsRunMode string
Run mode for the workflow event. The run mode allows the user to optimize for speed, accuracy, and cost by determining which models are used to evaluate the event. Available run modes (fastest to most thorough): `super_fast`, `fast`, `precision`, `precision_codex`, `precision_max`, and `precision_max_codex`. Defaults to `fast`. Note: `super_fast` does not support Web Search or File Search — if your workflow has these capabilities enabled, use a different run mode or edit the workflow to disable them.
const ( DefendSubmitEventParamsRunModeSuperFast DefendSubmitEventParamsRunMode = "super_fast" DefendSubmitEventParamsRunModeFast DefendSubmitEventParamsRunMode = "fast" DefendSubmitEventParamsRunModePrecision DefendSubmitEventParamsRunMode = "precision" DefendSubmitEventParamsRunModePrecisionCodex DefendSubmitEventParamsRunMode = "precision_codex" DefendSubmitEventParamsRunModePrecisionMax DefendSubmitEventParamsRunMode = "precision_max" DefendSubmitEventParamsRunModePrecisionMaxCodex DefendSubmitEventParamsRunMode = "precision_max_codex" )
func (DefendSubmitEventParamsRunMode) IsKnown ¶ added in v0.2.0
func (r DefendSubmitEventParamsRunMode) IsKnown() bool
type DefendUpdateResponse ¶ added in v0.12.0
type DefendUpdateResponse struct {
// The time the workflow was last modified in UTC.
ModifiedAt time.Time `json:"modified_at" api:"required" format:"date-time"`
// Status of the selected workflow. May be `inactive` or `active`. Inactive
// workflows will not accept events.
Status DefendUpdateResponseStatus `json:"status" api:"required"`
// A unique workflow ID.
WorkflowID string `json:"workflow_id" api:"required"`
// The name of the workflow.
Name string `json:"name"`
JSON defendUpdateResponseJSON `json:"-"`
}
func (*DefendUpdateResponse) UnmarshalJSON ¶ added in v0.12.0
func (r *DefendUpdateResponse) UnmarshalJSON(data []byte) (err error)
type DefendUpdateResponseStatus ¶ added in v0.12.0
type DefendUpdateResponseStatus string
Status of the selected workflow. May be `inactive` or `active`. Inactive workflows will not accept events.
const ( DefendUpdateResponseStatusInactive DefendUpdateResponseStatus = "inactive" DefendUpdateResponseStatusActive DefendUpdateResponseStatus = "active" )
func (DefendUpdateResponseStatus) IsKnown ¶ added in v0.12.0
func (r DefendUpdateResponseStatus) IsKnown() bool
type DefendUpdateWorkflowParams ¶
type DefendUpdateWorkflowParams struct {
// New mapping of guardrail metrics to hallucination tolerance levels (either
// `low`, `medium`, or `high`) to be used when `threshold_type` is set to
// `automatic`. Possible metrics are `completeness`, `instruction_adherence`,
// `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
AutomaticHallucinationToleranceLevels param.Field[map[string]DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels] `json:"automatic_hallucination_tolerance_levels"`
// Whether to enable context awareness for this workflow's evaluations.
ContextAwareness param.Field[bool] `json:"context_awareness"`
// New mapping of guardrail metrics to floating point threshold values to be used
// when `threshold_type` is set to `custom`. Possible metrics are `correctness`,
// `completeness`, `instruction_adherence`, `context_adherence`,
// `ground_truth_adherence`, or `comprehensive_safety`.
CustomHallucinationThresholdValues param.Field[map[string]float64] `json:"custom_hallucination_threshold_values"`
// New description for the workflow.
Description param.Field[string] `json:"description"`
// An array of file IDs to search in the workflow's evaluations. Files must be
// uploaded via the DeepRails API first.
FileSearch param.Field[[]string] `json:"file_search"`
// The new action used to improve outputs that fail one or more guardrail metrics
// for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
// the user's input prompt with minor induced variance. FixIt attempts to directly
// address the shortcomings of the output using the guardrail failure rationale. Do
// Nothing does not attempt any improvement.
ImprovementAction param.Field[DefendUpdateWorkflowParamsImprovementAction] `json:"improvement_action"`
// Max. number of improvement action attempts until a given event passes the
// guardrails. Defaults to 10.
MaxImprovementAttempts param.Field[int64] `json:"max_improvement_attempts"`
// New name for the workflow.
Name param.Field[string] `json:"name"`
// New type of thresholds to use for the workflow, either `automatic` or `custom`.
// Automatic thresholds are assigned internally after the user specifies a
// qualitative tolerance for the metrics, whereas custom metrics allow the user to
// set the threshold for each metric as a floating point number between 0.0 and
// 1.0.
ThresholdType param.Field[DefendUpdateWorkflowParamsThresholdType] `json:"threshold_type"`
// Whether to enable web search for this workflow's evaluations.
WebSearch param.Field[bool] `json:"web_search"`
}
func (DefendUpdateWorkflowParams) MarshalJSON ¶
func (r DefendUpdateWorkflowParams) MarshalJSON() (data []byte, err error)
type DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels ¶ added in v0.20.0
type DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels string
const ( DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevelsLow DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels = "low" DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevelsMedium DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels = "medium" DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevelsHigh DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels = "high" )
func (DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels) IsKnown ¶ added in v0.20.0
func (r DefendUpdateWorkflowParamsAutomaticHallucinationToleranceLevels) IsKnown() bool
type DefendUpdateWorkflowParamsImprovementAction ¶ added in v0.20.0
type DefendUpdateWorkflowParamsImprovementAction string
The new action used to improve outputs that fail one or more guardrail metrics for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the user's input prompt with minor induced variance. FixIt attempts to directly address the shortcomings of the output using the guardrail failure rationale. Do Nothing does not attempt any improvement.
const ( DefendUpdateWorkflowParamsImprovementActionRegen DefendUpdateWorkflowParamsImprovementAction = "regen" DefendUpdateWorkflowParamsImprovementActionFixit DefendUpdateWorkflowParamsImprovementAction = "fixit" DefendUpdateWorkflowParamsImprovementActionDoNothing DefendUpdateWorkflowParamsImprovementAction = "do_nothing" )
func (DefendUpdateWorkflowParamsImprovementAction) IsKnown ¶ added in v0.20.0
func (r DefendUpdateWorkflowParamsImprovementAction) IsKnown() bool
type DefendUpdateWorkflowParamsThresholdType ¶ added in v0.20.0
type DefendUpdateWorkflowParamsThresholdType string
New type of thresholds to use for the workflow, either `automatic` or `custom`. Automatic thresholds are assigned internally after the user specifies a qualitative tolerance for the metrics, whereas custom metrics allow the user to set the threshold for each metric as a floating point number between 0.0 and 1.0.
const ( DefendUpdateWorkflowParamsThresholdTypeAutomatic DefendUpdateWorkflowParamsThresholdType = "automatic" DefendUpdateWorkflowParamsThresholdTypeCustom DefendUpdateWorkflowParamsThresholdType = "custom" )
func (DefendUpdateWorkflowParamsThresholdType) IsKnown ¶ added in v0.20.0
func (r DefendUpdateWorkflowParamsThresholdType) IsKnown() bool
type FileResponse ¶ added in v0.10.0
type FileResponse struct {
// A unique file ID.
FileID string `json:"file_id"`
// Name of the file.
FileName string `json:"file_name"`
// The size of the file in bytes.
FileSize int64 `json:"file_size"`
JSON fileResponseJSON `json:"-"`
}
func (*FileResponse) UnmarshalJSON ¶ added in v0.10.0
func (r *FileResponse) UnmarshalJSON(data []byte) (err error)
type FileService ¶ added in v0.10.0
type FileService struct {
Options []option.RequestOption
}
FileService contains methods and other services that help with interacting with the deep rails API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFileService method instead.
func NewFileService ¶ added in v0.10.0
func NewFileService(opts ...option.RequestOption) (r *FileService)
NewFileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*FileService) Upload ¶ added in v0.10.0
func (r *FileService) Upload(ctx context.Context, body FileUploadParams, opts ...option.RequestOption) (res *FileResponse, err error)
Use this endpoint to upload a file to the DeepRails API
type FileUploadParams ¶ added in v0.10.0
type FileUploadParams struct {
// The contents of the files to upload.
Files param.Field[[]string] `json:"files" api:"required"`
}
func (FileUploadParams) MarshalMultipart ¶ added in v0.10.0
func (r FileUploadParams) MarshalMultipart() (data []byte, contentType string, err error)
type MonitorCreateResponse ¶ added in v0.12.0
type MonitorCreateResponse struct {
// The time the monitor was created in UTC.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// A unique monitor ID.
MonitorID string `json:"monitor_id" api:"required"`
// Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
// longer record and evaluate events.
Status MonitorCreateResponseStatus `json:"status" api:"required"`
JSON monitorCreateResponseJSON `json:"-"`
}
func (*MonitorCreateResponse) UnmarshalJSON ¶ added in v0.12.0
func (r *MonitorCreateResponse) UnmarshalJSON(data []byte) (err error)
type MonitorCreateResponseStatus ¶ added in v0.12.0
type MonitorCreateResponseStatus string
Status of the monitor. Can be `active` or `inactive`. Inactive monitors no longer record and evaluate events.
const ( MonitorCreateResponseStatusActive MonitorCreateResponseStatus = "active" MonitorCreateResponseStatusInactive MonitorCreateResponseStatus = "inactive" )
func (MonitorCreateResponseStatus) IsKnown ¶ added in v0.12.0
func (r MonitorCreateResponseStatus) IsKnown() bool
type MonitorDetailResponse ¶ added in v0.9.0
type MonitorDetailResponse struct {
// An array of extended AI capabilities associated with this monitor. Can be
// `web_search`, `file_search`, and/or `context_awareness`.
Capabilities []MonitorDetailResponseCapability `json:"capabilities" api:"required"`
// The time the monitor was created in UTC.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// An array of all evaluations performed by this monitor. Each one corresponds to a
// separate monitor event.
Evaluations []MonitorDetailResponseEvaluation `json:"evaluations" api:"required"`
// An array of files associated with this monitor.
Files []MonitorDetailResponseFile `json:"files" api:"required"`
// A unique monitor ID.
MonitorID string `json:"monitor_id" api:"required"`
// Name of this monitor.
Name string `json:"name" api:"required"`
// Contains five fields used for stats of this monitor: total evaluations,
// completed evaluations, failed evaluations, queued evaluations, and in progress
// evaluations.
Stats MonitorDetailResponseStats `json:"stats" api:"required"`
// Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
// longer record and evaluate events.
Status MonitorDetailResponseStatus `json:"status" api:"required"`
// The most recent time the monitor was modified in UTC.
UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"`
// Description of this monitor.
Description string `json:"description"`
JSON monitorDetailResponseJSON `json:"-"`
}
func (*MonitorDetailResponse) UnmarshalJSON ¶ added in v0.9.0
func (r *MonitorDetailResponse) UnmarshalJSON(data []byte) (err error)
type MonitorDetailResponseCapability ¶ added in v0.12.0
type MonitorDetailResponseCapability struct {
// The type of capability.
Capability string `json:"capability"`
JSON monitorDetailResponseCapabilityJSON `json:"-"`
}
func (*MonitorDetailResponseCapability) UnmarshalJSON ¶ added in v0.12.0
func (r *MonitorDetailResponseCapability) UnmarshalJSON(data []byte) (err error)
type MonitorDetailResponseEvaluation ¶ added in v0.9.0
type MonitorDetailResponseEvaluation struct {
// Status of the evaluation.
EvaluationStatus MonitorDetailResponseEvaluationsEvaluationStatus `json:"evaluation_status" api:"required"`
// A dictionary of inputs sent to the LLM to generate output. The dictionary must
// contain a `user_prompt` field. For ground_truth_adherence guardrail metric,
// `ground_truth` should be provided. When `context_awareness` is enabled,
// `context` should be provided.
ModelInput MonitorDetailResponseEvaluationsModelInput `json:"model_input" api:"required"`
// Output generated by the LLM to be evaluated.
ModelOutput string `json:"model_output" api:"required"`
// Run mode for the evaluation. The run mode allows the user to optimize for speed,
// accuracy, and cost by determining which models are used to evaluate the event.
// Note: `super_fast` do not support Web Search or File Search capabilities.
RunMode MonitorDetailResponseEvaluationsRunMode `json:"run_mode" api:"required"`
// The time the evaluation was created in UTC.
CreatedAt time.Time `json:"created_at" format:"date-time"`
// Error message if the evaluation failed.
ErrorMessage string `json:"error_message"`
// Evaluation result consisting of average scores and rationales for each of the
// evaluated guardrail metrics.
EvaluationResult map[string]interface{} `json:"evaluation_result"`
// Total cost of the evaluation.
EvaluationTotalCost float64 `json:"evaluation_total_cost"`
// An array of guardrail metrics that the input and output pair will be evaluated
// on.
GuardrailMetrics []MonitorDetailResponseEvaluationsGuardrailMetric `json:"guardrail_metrics"`
// An optional, user-defined tag for the evaluation.
Nametag string `json:"nametag"`
// Evaluation progress. Values range between 0 and 100; 100 corresponds to a
// completed `evaluation_status`.
Progress int64 `json:"progress"`
JSON monitorDetailResponseEvaluationJSON `json:"-"`
}
func (*MonitorDetailResponseEvaluation) UnmarshalJSON ¶ added in v0.9.0
func (r *MonitorDetailResponseEvaluation) UnmarshalJSON(data []byte) (err error)
type MonitorDetailResponseEvaluationsEvaluationStatus ¶ added in v0.9.0
type MonitorDetailResponseEvaluationsEvaluationStatus string
Status of the evaluation.
const ( MonitorDetailResponseEvaluationsEvaluationStatusInProgress MonitorDetailResponseEvaluationsEvaluationStatus = "in_progress" MonitorDetailResponseEvaluationsEvaluationStatusCompleted MonitorDetailResponseEvaluationsEvaluationStatus = "completed" MonitorDetailResponseEvaluationsEvaluationStatusCanceled MonitorDetailResponseEvaluationsEvaluationStatus = "canceled" MonitorDetailResponseEvaluationsEvaluationStatusQueued MonitorDetailResponseEvaluationsEvaluationStatus = "queued" MonitorDetailResponseEvaluationsEvaluationStatusFailed MonitorDetailResponseEvaluationsEvaluationStatus = "failed" )
func (MonitorDetailResponseEvaluationsEvaluationStatus) IsKnown ¶ added in v0.9.0
func (r MonitorDetailResponseEvaluationsEvaluationStatus) IsKnown() bool
type MonitorDetailResponseEvaluationsGuardrailMetric ¶ added in v0.9.0
type MonitorDetailResponseEvaluationsGuardrailMetric string
const ( MonitorDetailResponseEvaluationsGuardrailMetricCorrectness MonitorDetailResponseEvaluationsGuardrailMetric = "correctness" MonitorDetailResponseEvaluationsGuardrailMetricCompleteness MonitorDetailResponseEvaluationsGuardrailMetric = "completeness" MonitorDetailResponseEvaluationsGuardrailMetricInstructionAdherence MonitorDetailResponseEvaluationsGuardrailMetric = "instruction_adherence" MonitorDetailResponseEvaluationsGuardrailMetricContextAdherence MonitorDetailResponseEvaluationsGuardrailMetric = "context_adherence" MonitorDetailResponseEvaluationsGuardrailMetricGroundTruthAdherence MonitorDetailResponseEvaluationsGuardrailMetric = "ground_truth_adherence" MonitorDetailResponseEvaluationsGuardrailMetricComprehensiveSafety MonitorDetailResponseEvaluationsGuardrailMetric = "comprehensive_safety" )
func (MonitorDetailResponseEvaluationsGuardrailMetric) IsKnown ¶ added in v0.9.0
func (r MonitorDetailResponseEvaluationsGuardrailMetric) IsKnown() bool
type MonitorDetailResponseEvaluationsModelInput ¶ added in v0.9.0
type MonitorDetailResponseEvaluationsModelInput struct {
// The user prompt used to generate the output.
UserPrompt string `json:"user_prompt" api:"required"`
// Any structured information that directly relates to the model’s input and
// expected output—e.g., the recent turn-by-turn history between an AI tutor and a
// student, facts or state passed through an agentic workflow, or other
// domain-specific signals your system already knows and wants the model to
// condition on.
Context []MonitorDetailResponseEvaluationsModelInputContext `json:"context"`
// The ground truth for evaluating Ground Truth Adherence guardrail.
GroundTruth string `json:"ground_truth"`
// The system prompt used to generate the output.
SystemPrompt string `json:"system_prompt"`
JSON monitorDetailResponseEvaluationsModelInputJSON `json:"-"`
}
A dictionary of inputs sent to the LLM to generate output. The dictionary must contain a `user_prompt` field. For ground_truth_adherence guardrail metric, `ground_truth` should be provided. When `context_awareness` is enabled, `context` should be provided.
func (*MonitorDetailResponseEvaluationsModelInput) UnmarshalJSON ¶ added in v0.9.0
func (r *MonitorDetailResponseEvaluationsModelInput) UnmarshalJSON(data []byte) (err error)
type MonitorDetailResponseEvaluationsModelInputContext ¶ added in v0.22.0
type MonitorDetailResponseEvaluationsModelInputContext struct {
// The content of the message.
Content string `json:"content"`
// The role of the speaker.
Role string `json:"role"`
JSON monitorDetailResponseEvaluationsModelInputContextJSON `json:"-"`
}
func (*MonitorDetailResponseEvaluationsModelInputContext) UnmarshalJSON ¶ added in v0.22.0
func (r *MonitorDetailResponseEvaluationsModelInputContext) UnmarshalJSON(data []byte) (err error)
type MonitorDetailResponseEvaluationsRunMode ¶ added in v0.9.0
type MonitorDetailResponseEvaluationsRunMode string
Run mode for the evaluation. The run mode allows the user to optimize for speed, accuracy, and cost by determining which models are used to evaluate the event. Note: `super_fast` do not support Web Search or File Search capabilities.
const ( MonitorDetailResponseEvaluationsRunModeSuperFast MonitorDetailResponseEvaluationsRunMode = "super_fast" MonitorDetailResponseEvaluationsRunModeFast MonitorDetailResponseEvaluationsRunMode = "fast" MonitorDetailResponseEvaluationsRunModePrecision MonitorDetailResponseEvaluationsRunMode = "precision" MonitorDetailResponseEvaluationsRunModePrecisionCodex MonitorDetailResponseEvaluationsRunMode = "precision_codex" MonitorDetailResponseEvaluationsRunModePrecisionMax MonitorDetailResponseEvaluationsRunMode = "precision_max" MonitorDetailResponseEvaluationsRunModePrecisionMaxCodex MonitorDetailResponseEvaluationsRunMode = "precision_max_codex" )
func (MonitorDetailResponseEvaluationsRunMode) IsKnown ¶ added in v0.9.0
func (r MonitorDetailResponseEvaluationsRunMode) IsKnown() bool
type MonitorDetailResponseFile ¶ added in v0.12.0
type MonitorDetailResponseFile struct {
// The ID of the file.
FileID string `json:"file_id"`
// The name of the file.
FileName string `json:"file_name"`
// The size of the file in bytes.
FileSize int64 `json:"file_size"`
JSON monitorDetailResponseFileJSON `json:"-"`
}
func (*MonitorDetailResponseFile) UnmarshalJSON ¶ added in v0.12.0
func (r *MonitorDetailResponseFile) UnmarshalJSON(data []byte) (err error)
type MonitorDetailResponseStats ¶ added in v0.9.0
type MonitorDetailResponseStats struct {
// Number of evaluations that completed successfully.
CompletedEvaluations int64 `json:"completed_evaluations"`
// Number of evaluations that failed.
FailedEvaluations int64 `json:"failed_evaluations"`
// Number of evaluations currently in progress.
InProgressEvaluations int64 `json:"in_progress_evaluations"`
// Number of evaluations currently queued.
QueuedEvaluations int64 `json:"queued_evaluations"`
// Total number of evaluations performed by this monitor.
TotalEvaluations int64 `json:"total_evaluations"`
JSON monitorDetailResponseStatsJSON `json:"-"`
}
Contains five fields used for stats of this monitor: total evaluations, completed evaluations, failed evaluations, queued evaluations, and in progress evaluations.
func (*MonitorDetailResponseStats) UnmarshalJSON ¶ added in v0.9.0
func (r *MonitorDetailResponseStats) UnmarshalJSON(data []byte) (err error)
type MonitorDetailResponseStatus ¶ added in v0.12.0
type MonitorDetailResponseStatus string
Status of the monitor. Can be `active` or `inactive`. Inactive monitors no longer record and evaluate events.
const ( MonitorDetailResponseStatusActive MonitorDetailResponseStatus = "active" MonitorDetailResponseStatusInactive MonitorDetailResponseStatus = "inactive" )
func (MonitorDetailResponseStatus) IsKnown ¶ added in v0.12.0
func (r MonitorDetailResponseStatus) IsKnown() bool
type MonitorEventDetailResponse ¶ added in v0.13.0
type MonitorEventDetailResponse struct {
// The extended AI capabilities associated with the monitor event. Can be
// `web_search`, `file_search`, and/or `context_awareness`.
Capabilities []MonitorEventDetailResponseCapability `json:"capabilities"`
// The time spent on the evaluation in seconds.
EvalTime string `json:"eval_time"`
// The result of the evaluation of the monitor event.
EvaluationResult map[string]interface{} `json:"evaluation_result"`
// A unique monitor event ID.
EventID string `json:"event_id"`
// The files associated with the monitor event.
Files []MonitorEventDetailResponseFile `json:"files"`
// The guardrail metrics evaluated by the monitor event.
GuardrailMetrics []string `json:"guardrail_metrics"`
// The model input used to create the monitor event.
ModelInput map[string]interface{} `json:"model_input"`
// The output evaluated by the monitor event.
ModelOutput string `json:"model_output"`
// Monitor ID associated with this event.
MonitorID string `json:"monitor_id"`
// A human-readable tag for the monitor event.
Nametag string `json:"nametag"`
// The run mode used to evaluate the monitor event.
RunMode MonitorEventDetailResponseRunMode `json:"run_mode"`
// Status of the monitor event's evaluation.
Status MonitorEventDetailResponseStatus `json:"status"`
// The time the monitor event was created in UTC.
Timestamp time.Time `json:"timestamp" format:"date-time"`
JSON monitorEventDetailResponseJSON `json:"-"`
}
func (*MonitorEventDetailResponse) UnmarshalJSON ¶ added in v0.13.0
func (r *MonitorEventDetailResponse) UnmarshalJSON(data []byte) (err error)
type MonitorEventDetailResponseCapability ¶ added in v0.13.0
type MonitorEventDetailResponseCapability struct {
// The type of capability.
Capability string `json:"capability"`
JSON monitorEventDetailResponseCapabilityJSON `json:"-"`
}
func (*MonitorEventDetailResponseCapability) UnmarshalJSON ¶ added in v0.13.0
func (r *MonitorEventDetailResponseCapability) UnmarshalJSON(data []byte) (err error)
type MonitorEventDetailResponseFile ¶ added in v0.13.0
type MonitorEventDetailResponseFile struct {
// The ID of the file.
FileID string `json:"file_id"`
// The name of the file.
FileName string `json:"file_name"`
// The size of the file in bytes.
FileSize int64 `json:"file_size"`
JSON monitorEventDetailResponseFileJSON `json:"-"`
}
func (*MonitorEventDetailResponseFile) UnmarshalJSON ¶ added in v0.13.0
func (r *MonitorEventDetailResponseFile) UnmarshalJSON(data []byte) (err error)
type MonitorEventDetailResponseRunMode ¶ added in v0.13.0
type MonitorEventDetailResponseRunMode string
The run mode used to evaluate the monitor event.
const ( MonitorEventDetailResponseRunModeSuperFast MonitorEventDetailResponseRunMode = "super_fast" MonitorEventDetailResponseRunModeFast MonitorEventDetailResponseRunMode = "fast" MonitorEventDetailResponseRunModePrecision MonitorEventDetailResponseRunMode = "precision" MonitorEventDetailResponseRunModePrecisionCodex MonitorEventDetailResponseRunMode = "precision_codex" MonitorEventDetailResponseRunModePrecisionMax MonitorEventDetailResponseRunMode = "precision_max" MonitorEventDetailResponseRunModePrecisionMaxCodex MonitorEventDetailResponseRunMode = "precision_max_codex" )
func (MonitorEventDetailResponseRunMode) IsKnown ¶ added in v0.13.0
func (r MonitorEventDetailResponseRunMode) IsKnown() bool
type MonitorEventDetailResponseStatus ¶ added in v0.13.0
type MonitorEventDetailResponseStatus string
Status of the monitor event's evaluation.
const ( MonitorEventDetailResponseStatusInProgress MonitorEventDetailResponseStatus = "in_progress" MonitorEventDetailResponseStatusCompleted MonitorEventDetailResponseStatus = "completed" MonitorEventDetailResponseStatusCanceled MonitorEventDetailResponseStatus = "canceled" MonitorEventDetailResponseStatusQueued MonitorEventDetailResponseStatus = "queued" MonitorEventDetailResponseStatusFailed MonitorEventDetailResponseStatus = "failed" )
func (MonitorEventDetailResponseStatus) IsKnown ¶ added in v0.13.0
func (r MonitorEventDetailResponseStatus) IsKnown() bool
type MonitorEventResponse ¶ added in v0.9.0
type MonitorEventResponse struct {
// A unique monitor event ID.
EventID string `json:"event_id" api:"required"`
// Monitor ID associated with this event.
MonitorID string `json:"monitor_id" api:"required"`
// The time the monitor event was created in UTC.
CreatedAt time.Time `json:"created_at" format:"date-time"`
JSON monitorEventResponseJSON `json:"-"`
}
func (*MonitorEventResponse) UnmarshalJSON ¶ added in v0.9.0
func (r *MonitorEventResponse) UnmarshalJSON(data []byte) (err error)
type MonitorGetParams ¶
type MonitorGetParams struct {
// Limit the number of returned evaluations associated with this monitor. Defaults
// to 10.
Limit param.Field[int64] `query:"limit"`
}
func (MonitorGetParams) URLQuery ¶
func (r MonitorGetParams) URLQuery() (v url.Values)
URLQuery serializes MonitorGetParams's query parameters as `url.Values`.
type MonitorNewParams ¶
type MonitorNewParams struct {
// An array of guardrail metrics that the model input and output pair will be
// evaluated on. For non-enterprise users, these will be limited to `correctness`,
// `completeness`, `instruction_adherence`, `context_adherence`,
// `ground_truth_adherence`, and/or `comprehensive_safety`.
GuardrailMetrics param.Field[[]MonitorNewParamsGuardrailMetric] `json:"guardrail_metrics" api:"required"`
// Name of the new monitor.
Name param.Field[string] `json:"name" api:"required"`
// Context includes any structured information that directly relates to the model’s
// input and expected output—e.g., the recent turn-by-turn history between an AI
// tutor and a student, facts or state passed through an agentic workflow, or other
// domain-specific signals your system already knows and wants the model to
// condition on. This field determines whether to enable context awareness for this
// monitor's evaluations. Defaults to false.
ContextAwareness param.Field[bool] `json:"context_awareness"`
// Description of the new monitor.
Description param.Field[string] `json:"description"`
// An array of file IDs to search in the monitor's evaluations. Files must be
// uploaded via the DeepRails API first.
FileSearch param.Field[[]string] `json:"file_search"`
// Whether to enable web search for this monitor's evaluations. Defaults to false.
WebSearch param.Field[bool] `json:"web_search"`
}
func (MonitorNewParams) MarshalJSON ¶
func (r MonitorNewParams) MarshalJSON() (data []byte, err error)
type MonitorNewParamsGuardrailMetric ¶ added in v0.11.0
type MonitorNewParamsGuardrailMetric string
const ( MonitorNewParamsGuardrailMetricCorrectness MonitorNewParamsGuardrailMetric = "correctness" MonitorNewParamsGuardrailMetricCompleteness MonitorNewParamsGuardrailMetric = "completeness" MonitorNewParamsGuardrailMetricInstructionAdherence MonitorNewParamsGuardrailMetric = "instruction_adherence" MonitorNewParamsGuardrailMetricContextAdherence MonitorNewParamsGuardrailMetric = "context_adherence" MonitorNewParamsGuardrailMetricGroundTruthAdherence MonitorNewParamsGuardrailMetric = "ground_truth_adherence" MonitorNewParamsGuardrailMetricComprehensiveSafety MonitorNewParamsGuardrailMetric = "comprehensive_safety" )
func (MonitorNewParamsGuardrailMetric) IsKnown ¶ added in v0.11.0
func (r MonitorNewParamsGuardrailMetric) IsKnown() bool
type MonitorService ¶
type MonitorService struct {
Options []option.RequestOption
}
MonitorService contains methods and other services that help with interacting with the deep rails API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMonitorService method instead.
func NewMonitorService ¶
func NewMonitorService(opts ...option.RequestOption) (r *MonitorService)
NewMonitorService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*MonitorService) Get ¶
func (r *MonitorService) Get(ctx context.Context, monitorID string, query MonitorGetParams, opts ...option.RequestOption) (res *MonitorDetailResponse, err error)
Use this endpoint to retrieve the details and evaluations associated with a specific monitor
func (*MonitorService) GetEvent ¶ added in v0.13.0
func (r *MonitorService) GetEvent(ctx context.Context, monitorID string, eventID string, opts ...option.RequestOption) (res *MonitorEventDetailResponse, err error)
Use this endpoint to retrieve the details of a specific monitor event
func (*MonitorService) New ¶
func (r *MonitorService) New(ctx context.Context, body MonitorNewParams, opts ...option.RequestOption) (res *MonitorCreateResponse, err error)
Use this endpoint to create a new monitor to evaluate model inputs and outputs using guardrails
func (*MonitorService) SubmitEvent ¶
func (r *MonitorService) SubmitEvent(ctx context.Context, monitorID string, body MonitorSubmitEventParams, opts ...option.RequestOption) (res *MonitorEventResponse, err error)
Use this endpoint to submit a model input and output pair to a monitor for evaluation
func (*MonitorService) Update ¶
func (r *MonitorService) Update(ctx context.Context, monitorID string, body MonitorUpdateParams, opts ...option.RequestOption) (res *MonitorUpdateResponse, err error)
Use this endpoint to update the name, status, and/or other details of an existing monitor.
type MonitorSubmitEventParams ¶
type MonitorSubmitEventParams struct {
// A dictionary of inputs sent to the LLM to generate output. The dictionary must
// contain a `user_prompt` field. For ground_truth_adherence guardrail metric,
// `ground_truth` should be provided.
ModelInput param.Field[MonitorSubmitEventParamsModelInput] `json:"model_input" api:"required"`
// Output generated by the LLM to be evaluated.
ModelOutput param.Field[string] `json:"model_output" api:"required"`
// An optional, user-defined tag for the event.
Nametag param.Field[string] `json:"nametag"`
// Run mode for the monitor event. The run mode allows the user to optimize for
// speed, accuracy, and cost by determining which models are used to evaluate the
// event. Available run modes (fastest to most thorough): `super_fast`, `fast`,
// `precision`, `precision_codex`, `precision_max`, and `precision_max_codex`.
// Defaults to `fast`. Note: `super_fast` does not support Web Search or File
// Search — if your monitor has these capabilities enabled, use a different run
// mode or edit the monitor to disable them.
RunMode param.Field[MonitorSubmitEventParamsRunMode] `json:"run_mode"`
}
func (MonitorSubmitEventParams) MarshalJSON ¶
func (r MonitorSubmitEventParams) MarshalJSON() (data []byte, err error)
type MonitorSubmitEventParamsModelInput ¶
type MonitorSubmitEventParamsModelInput struct {
// The user prompt used to generate the output.
UserPrompt param.Field[string] `json:"user_prompt" api:"required"`
// Any structured information that directly relates to the model’s input and
// expected output—e.g., the recent turn-by-turn history between an AI tutor and a
// student, facts or state passed through an agentic workflow, or other
// domain-specific signals your system already knows and wants the model to
// condition on.
Context param.Field[[]MonitorSubmitEventParamsModelInputContext] `json:"context"`
// The ground truth for evaluating Ground Truth Adherence guardrail.
GroundTruth param.Field[string] `json:"ground_truth"`
// The system prompt used to generate the output.
SystemPrompt param.Field[string] `json:"system_prompt"`
}
A dictionary of inputs sent to the LLM to generate output. The dictionary must contain a `user_prompt` field. For ground_truth_adherence guardrail metric, `ground_truth` should be provided.
func (MonitorSubmitEventParamsModelInput) MarshalJSON ¶
func (r MonitorSubmitEventParamsModelInput) MarshalJSON() (data []byte, err error)
type MonitorSubmitEventParamsModelInputContext ¶ added in v0.22.0
type MonitorSubmitEventParamsModelInputContext struct {
// The content of the message.
Content param.Field[string] `json:"content"`
// The role of the speaker.
Role param.Field[string] `json:"role"`
}
func (MonitorSubmitEventParamsModelInputContext) MarshalJSON ¶ added in v0.22.0
func (r MonitorSubmitEventParamsModelInputContext) MarshalJSON() (data []byte, err error)
type MonitorSubmitEventParamsRunMode ¶
type MonitorSubmitEventParamsRunMode string
Run mode for the monitor event. The run mode allows the user to optimize for speed, accuracy, and cost by determining which models are used to evaluate the event. Available run modes (fastest to most thorough): `super_fast`, `fast`, `precision`, `precision_codex`, `precision_max`, and `precision_max_codex`. Defaults to `fast`. Note: `super_fast` does not support Web Search or File Search — if your monitor has these capabilities enabled, use a different run mode or edit the monitor to disable them.
const ( MonitorSubmitEventParamsRunModeSuperFast MonitorSubmitEventParamsRunMode = "super_fast" MonitorSubmitEventParamsRunModeFast MonitorSubmitEventParamsRunMode = "fast" MonitorSubmitEventParamsRunModePrecision MonitorSubmitEventParamsRunMode = "precision" MonitorSubmitEventParamsRunModePrecisionCodex MonitorSubmitEventParamsRunMode = "precision_codex" MonitorSubmitEventParamsRunModePrecisionMax MonitorSubmitEventParamsRunMode = "precision_max" MonitorSubmitEventParamsRunModePrecisionMaxCodex MonitorSubmitEventParamsRunMode = "precision_max_codex" )
func (MonitorSubmitEventParamsRunMode) IsKnown ¶ added in v0.2.0
func (r MonitorSubmitEventParamsRunMode) IsKnown() bool
type MonitorUpdateParams ¶
type MonitorUpdateParams struct {
// New description of the monitor.
Description param.Field[string] `json:"description"`
// An array of file IDs to search in the monitor's evaluations. Files must be
// uploaded via the DeepRails API first.
FileSearch param.Field[[]string] `json:"file_search"`
// An array of the new guardrail metrics that model input and output pairs will be
// evaluated on.
GuardrailMetrics param.Field[[]MonitorUpdateParamsGuardrailMetric] `json:"guardrail_metrics"`
// New name of the monitor.
Name param.Field[string] `json:"name"`
// Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
// longer record and evaluate events.
Status param.Field[MonitorUpdateParamsStatus] `json:"status"`
// Whether to enable web search for this monitor's evaluations.
WebSearch param.Field[bool] `json:"web_search"`
}
func (MonitorUpdateParams) MarshalJSON ¶
func (r MonitorUpdateParams) MarshalJSON() (data []byte, err error)
type MonitorUpdateParamsGuardrailMetric ¶ added in v0.20.0
type MonitorUpdateParamsGuardrailMetric string
const ( MonitorUpdateParamsGuardrailMetricCorrectness MonitorUpdateParamsGuardrailMetric = "correctness" MonitorUpdateParamsGuardrailMetricCompleteness MonitorUpdateParamsGuardrailMetric = "completeness" MonitorUpdateParamsGuardrailMetricInstructionAdherence MonitorUpdateParamsGuardrailMetric = "instruction_adherence" MonitorUpdateParamsGuardrailMetricContextAdherence MonitorUpdateParamsGuardrailMetric = "context_adherence" MonitorUpdateParamsGuardrailMetricGroundTruthAdherence MonitorUpdateParamsGuardrailMetric = "ground_truth_adherence" MonitorUpdateParamsGuardrailMetricComprehensiveSafety MonitorUpdateParamsGuardrailMetric = "comprehensive_safety" )
func (MonitorUpdateParamsGuardrailMetric) IsKnown ¶ added in v0.20.0
func (r MonitorUpdateParamsGuardrailMetric) IsKnown() bool
type MonitorUpdateParamsStatus ¶ added in v0.12.0
type MonitorUpdateParamsStatus string
Status of the monitor. Can be `active` or `inactive`. Inactive monitors no longer record and evaluate events.
const ( MonitorUpdateParamsStatusActive MonitorUpdateParamsStatus = "active" MonitorUpdateParamsStatusInactive MonitorUpdateParamsStatus = "inactive" )
func (MonitorUpdateParamsStatus) IsKnown ¶ added in v0.12.0
func (r MonitorUpdateParamsStatus) IsKnown() bool
type MonitorUpdateResponse ¶ added in v0.12.0
type MonitorUpdateResponse struct {
// The time the monitor was last modified in UTC.
ModifiedAt time.Time `json:"modified_at" api:"required" format:"date-time"`
// A unique monitor ID.
MonitorID string `json:"monitor_id" api:"required"`
// Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
// longer record and evaluate events.
Status MonitorUpdateResponseStatus `json:"status" api:"required"`
JSON monitorUpdateResponseJSON `json:"-"`
}
func (*MonitorUpdateResponse) UnmarshalJSON ¶ added in v0.12.0
func (r *MonitorUpdateResponse) UnmarshalJSON(data []byte) (err error)
type MonitorUpdateResponseStatus ¶ added in v0.12.0
type MonitorUpdateResponseStatus string
Status of the monitor. Can be `active` or `inactive`. Inactive monitors no longer record and evaluate events.
const ( MonitorUpdateResponseStatusActive MonitorUpdateResponseStatus = "active" MonitorUpdateResponseStatusInactive MonitorUpdateResponseStatus = "inactive" )
func (MonitorUpdateResponseStatus) IsKnown ¶ added in v0.12.0
func (r MonitorUpdateResponseStatus) IsKnown() bool
type WorkflowEventDetailResponse ¶ added in v0.12.0
type WorkflowEventDetailResponse struct {
AnalysisOfFailures []string `json:"analysis_of_failures" api:"required"`
// History of evaluations for the event.
EvaluationHistory []WorkflowEventDetailResponseEvaluationHistory `json:"evaluation_history" api:"required"`
// Evaluation result consisting of average scores and rationales for each of the
// evaluated guardrail metrics.
EvaluationResult map[string]interface{} `json:"evaluation_result" api:"required"`
// A unique workflow event ID.
EventID string `json:"event_id" api:"required"`
// Whether the event was filtered and requires improvement.
Filtered bool `json:"filtered" api:"required"`
// Improved model output after improvement tool was applied and each metric passed
// evaluation.
ImprovedModelOutput string `json:"improved_model_output" api:"required"`
// Type of improvement action used to improve the event.
ImprovementAction WorkflowEventDetailResponseImprovementAction `json:"improvement_action" api:"required"`
// Status of the improvement tool used to improve the event. `improvement_required`
// indicates that the evaluation is complete and the improvement action is needed
// but is not taking place. `improved` and `improvement_failed` indicate when the
// improvement action concludes, successfully and unsuccessfully, respectively.
// `no_improvement_required` means that the first evaluation passed all its
// metrics!
ImprovementToolStatus WorkflowEventDetailResponseImprovementToolStatus `json:"improvement_tool_status" api:"required,nullable"`
KeyImprovements []WorkflowEventDetailResponseKeyImprovement `json:"key_improvements" api:"required"`
// Status of the event.
Status WorkflowEventDetailResponseStatus `json:"status" api:"required"`
// Type of thresholds used to evaluate the event.
ThresholdType WorkflowEventDetailResponseThresholdType `json:"threshold_type" api:"required"`
// Workflow ID associated with the event.
WorkflowID string `json:"workflow_id" api:"required"`
// Mapping of guardrail metric names to tolerance values. Values are strings
// (`low`, `medium`, `high`) representing automatic tolerance levels.
AutomaticHallucinationToleranceLevels map[string]WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel `json:"automatic_hallucination_tolerance_levels"`
// Extended AI capabilities available to the event, if any. Can be `web_search`,
// `file_search`, and/or `context_awareness`.
Capabilities []WorkflowEventDetailResponseCapability `json:"capabilities"`
// Mapping of guardrail metric names to threshold values. Values are floating point
// numbers (0.0-1.0) representing custom thresholds.
CustomHallucinationThresholdValues map[string]float64 `json:"custom_hallucination_threshold_values"`
// List of files available to the event, if any. Will only be present if
// `file_search` is enabled.
Files []WorkflowEventDetailResponseFile `json:"files"`
// The maximum number of improvement attempts to be applied to one event before it
// is considered failed.
MaxImprovementAttempts int64 `json:"max_improvement_attempts"`
JSON workflowEventDetailResponseJSON `json:"-"`
}
func (*WorkflowEventDetailResponse) UnmarshalJSON ¶ added in v0.12.0
func (r *WorkflowEventDetailResponse) UnmarshalJSON(data []byte) (err error)
type WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel ¶ added in v0.12.0
type WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel string
const ( WorkflowEventDetailResponseAutomaticHallucinationToleranceLevelLow WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel = "low" WorkflowEventDetailResponseAutomaticHallucinationToleranceLevelMedium WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel = "medium" WorkflowEventDetailResponseAutomaticHallucinationToleranceLevelHigh WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel = "high" )
func (WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel) IsKnown ¶ added in v0.12.0
func (r WorkflowEventDetailResponseAutomaticHallucinationToleranceLevel) IsKnown() bool
type WorkflowEventDetailResponseCapability ¶ added in v0.12.0
type WorkflowEventDetailResponseCapability struct {
Capability string `json:"capability"`
JSON workflowEventDetailResponseCapabilityJSON `json:"-"`
}
func (*WorkflowEventDetailResponseCapability) UnmarshalJSON ¶ added in v0.12.0
func (r *WorkflowEventDetailResponseCapability) UnmarshalJSON(data []byte) (err error)
type WorkflowEventDetailResponseEvaluationHistory ¶ added in v0.12.0
type WorkflowEventDetailResponseEvaluationHistory struct {
AnalysisOfFailures string `json:"analysis_of_failures"`
Attempt string `json:"attempt"`
CreatedAt time.Time `json:"created_at" format:"date-time"`
ErrorMessage string `json:"error_message"`
EvaluationResult map[string]interface{} `json:"evaluation_result"`
EvaluationStatus string `json:"evaluation_status"`
EvaluationTotalCost float64 `json:"evaluation_total_cost"`
GuardrailMetrics []string `json:"guardrail_metrics"`
ImprovementToolStatus WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus `json:"improvement_tool_status"`
KeyImprovements []string `json:"key_improvements"`
ModelInput map[string]interface{} `json:"model_input"`
ModelOutput string `json:"model_output"`
Nametag string `json:"nametag"`
Progress int64 `json:"progress"`
RunMode string `json:"run_mode"`
JSON workflowEventDetailResponseEvaluationHistoryJSON `json:"-"`
}
func (*WorkflowEventDetailResponseEvaluationHistory) UnmarshalJSON ¶ added in v0.12.0
func (r *WorkflowEventDetailResponseEvaluationHistory) UnmarshalJSON(data []byte) (err error)
type WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus ¶ added in v0.22.0
type WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus string
const ( WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatusImproved WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus = "improved" WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatusImprovementFailed WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus = "improvement_failed" WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatusNoImprovementRequired WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus = "no_improvement_required" WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatusImprovementRequired WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus = "improvement_required" )
func (WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus) IsKnown ¶ added in v0.22.0
func (r WorkflowEventDetailResponseEvaluationHistoryImprovementToolStatus) IsKnown() bool
type WorkflowEventDetailResponseFile ¶ added in v0.12.0
type WorkflowEventDetailResponseFile struct {
FileID string `json:"file_id"`
FileName string `json:"file_name"`
FileSize int64 `json:"file_size"`
PresignedURL string `json:"presigned_url"`
PresignedURLExpiresAt time.Time `json:"presigned_url_expires_at" format:"date-time"`
JSON workflowEventDetailResponseFileJSON `json:"-"`
}
func (*WorkflowEventDetailResponseFile) UnmarshalJSON ¶ added in v0.12.0
func (r *WorkflowEventDetailResponseFile) UnmarshalJSON(data []byte) (err error)
type WorkflowEventDetailResponseImprovementAction ¶ added in v0.14.0
type WorkflowEventDetailResponseImprovementAction string
Type of improvement action used to improve the event.
const ( WorkflowEventDetailResponseImprovementActionRegen WorkflowEventDetailResponseImprovementAction = "regen" WorkflowEventDetailResponseImprovementActionFixit WorkflowEventDetailResponseImprovementAction = "fixit" WorkflowEventDetailResponseImprovementActionDoNothing WorkflowEventDetailResponseImprovementAction = "do_nothing" )
func (WorkflowEventDetailResponseImprovementAction) IsKnown ¶ added in v0.14.0
func (r WorkflowEventDetailResponseImprovementAction) IsKnown() bool
type WorkflowEventDetailResponseImprovementToolStatus ¶ added in v0.12.0
type WorkflowEventDetailResponseImprovementToolStatus string
Status of the improvement tool used to improve the event. `improvement_required` indicates that the evaluation is complete and the improvement action is needed but is not taking place. `improved` and `improvement_failed` indicate when the improvement action concludes, successfully and unsuccessfully, respectively. `no_improvement_required` means that the first evaluation passed all its metrics!
const ( WorkflowEventDetailResponseImprovementToolStatusImproved WorkflowEventDetailResponseImprovementToolStatus = "improved" WorkflowEventDetailResponseImprovementToolStatusImprovementFailed WorkflowEventDetailResponseImprovementToolStatus = "improvement_failed" WorkflowEventDetailResponseImprovementToolStatusNoImprovementRequired WorkflowEventDetailResponseImprovementToolStatus = "no_improvement_required" WorkflowEventDetailResponseImprovementToolStatusImprovementRequired WorkflowEventDetailResponseImprovementToolStatus = "improvement_required" )
func (WorkflowEventDetailResponseImprovementToolStatus) IsKnown ¶ added in v0.12.0
func (r WorkflowEventDetailResponseImprovementToolStatus) IsKnown() bool
type WorkflowEventDetailResponseKeyImprovement ¶ added in v0.24.0
type WorkflowEventDetailResponseKeyImprovement struct {
KeyImprovement []string `json:"key_improvement"`
JSON workflowEventDetailResponseKeyImprovementJSON `json:"-"`
}
func (*WorkflowEventDetailResponseKeyImprovement) UnmarshalJSON ¶ added in v0.24.0
func (r *WorkflowEventDetailResponseKeyImprovement) UnmarshalJSON(data []byte) (err error)
type WorkflowEventDetailResponseStatus ¶ added in v0.17.0
type WorkflowEventDetailResponseStatus string
Status of the event.
const ( WorkflowEventDetailResponseStatusInProgress WorkflowEventDetailResponseStatus = "In Progress" WorkflowEventDetailResponseStatusCompleted WorkflowEventDetailResponseStatus = "Completed" )
func (WorkflowEventDetailResponseStatus) IsKnown ¶ added in v0.17.0
func (r WorkflowEventDetailResponseStatus) IsKnown() bool
type WorkflowEventDetailResponseThresholdType ¶ added in v0.12.0
type WorkflowEventDetailResponseThresholdType string
Type of thresholds used to evaluate the event.
const ( WorkflowEventDetailResponseThresholdTypeCustom WorkflowEventDetailResponseThresholdType = "custom" WorkflowEventDetailResponseThresholdTypeAutomatic WorkflowEventDetailResponseThresholdType = "automatic" )
func (WorkflowEventDetailResponseThresholdType) IsKnown ¶ added in v0.12.0
func (r WorkflowEventDetailResponseThresholdType) IsKnown() bool
type WorkflowEventResponse ¶
type WorkflowEventResponse struct {
// The ID of the billing request for the event.
BillingRequestID string `json:"billing_request_id" api:"required"`
// The time the event was created in UTC.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// A unique workflow event ID.
EventID string `json:"event_id" api:"required"`
// Status of the event.
Status WorkflowEventResponseStatus `json:"status" api:"required"`
// Workflow ID associated with the event.
WorkflowID string `json:"workflow_id" api:"required"`
JSON workflowEventResponseJSON `json:"-"`
}
func (*WorkflowEventResponse) UnmarshalJSON ¶
func (r *WorkflowEventResponse) UnmarshalJSON(data []byte) (err error)
type WorkflowEventResponseStatus ¶ added in v0.12.0
type WorkflowEventResponseStatus string
Status of the event.
const ( WorkflowEventResponseStatusInProgress WorkflowEventResponseStatus = "In Progress" WorkflowEventResponseStatusCompleted WorkflowEventResponseStatus = "Completed" )
func (WorkflowEventResponseStatus) IsKnown ¶ added in v0.12.0
func (r WorkflowEventResponseStatus) IsKnown() bool