Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get validator metrics #4

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions service-specs/guardrails-service-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,15 @@ components:
type: object
properties:
schema:
type: object
additionalProperties:
$ref: "#/components/schemas/DataType"
oneOf:
- $ref: "#/components/schemas/JsonSchema"
- $ref: "#/components/schemas/DataType"
required:
- schema
JsonSchema:
type: object
additionalProperties:
$ref: "#/components/schemas/DataType"
DataType:
type: object
properties:
Expand Down
113 changes: 113 additions & 0 deletions service-specs/reporting-service-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,62 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/HttpError"
/validators/metrics:
get:
operationId: getValidatorMetrics
summary: Returns an array of ValidatorMetrics for a given time range. If startTime or endTime are ommitted, a five minute duration is used by default. Default page size is 10, but this page size applied to guard steps not validator metrics. Have to think this one out a little more.
parameters:
- $ref: "#/components/parameters/StartTime"
- $ref: "#/components/parameters/EndTime"
- $ref: "#/components/parameters/PageNumber"
tags:
- Metrics
security:
- apiKeyAuth: []
- bearerAuth: []
responses:
"200":
description: Returns metrics for Guards
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ValidatorMetrics"
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/HttpError"
/validators/{validatorName}/runs/{requestId}/instances/{validatorInstanceId}/metrics:
get:
operationId: getValidatorRunMetrics
summary: Returns an arary of ValidatorRunMetrics for a given request.
parameters:
- $ref: "#/components/parameters/ValidatorName"
- $ref: "#/components/parameters/RequestId"
- $ref: "#/components/parameters/ValidatorInstanceId"
tags:
- Metrics
security:
- apiKeyAuth: []
- bearerAuth: []
responses:
"200":
description: Returns metrics for Guard request
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ValidatorRunMetrics"
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/HttpError"
components:
securitySchemes:
bearerAuth:
Expand Down Expand Up @@ -206,8 +262,14 @@ components:
ValidatorMetrics:
type: object
properties:
instanceId:
type: string
name:
type: string
requestId:
type: string
guardName:
type: string
startTime:
type: string
format: date-time
Expand All @@ -226,13 +288,50 @@ components:
type: number
description: The number of tokens consumed if the validator calls an LLM. Only applies to validators that call LLMs.
required:
- instanceId
- name
- requestId
- guardName
- startTime
- endTime
- durationInMillis
- input
- output
- status
ValidatorRunMetrics:
allOf:
- $ref: '#/components/schemas/ValidatorMetrics'
- $ref: '#/components/schemas/ValidatorRunMetricDetails'
ValidatorRunMetricDetails:
type: object
properties:
stepNumber:
type: integer
resultType:
type: string
failAction:
$ref: '#/components/schemas/OnFailOptions'
parameters:
type: object
properties: {}
additionalProperties:
type: string
required:
- stepNumber
- resultType
- failAction
- parameters
OnFailOptions:
type: string
enum: [
"exception",
"filter",
"fix",
"fix_reask",
"noop",
"reask",
"refrain"
]
parameters:
StartTime:
name: startTime
Expand Down Expand Up @@ -270,5 +369,19 @@ components:
in: path
description: Request id aka trace id for a validate-{guard-name} span
required: true
schema:
type: string
ValidatorName:
name: validatorName
in: path
description: the validator's registered name
required: true
schema:
type: string
ValidatorInstanceId:
name: validatorInstanceId
in: path
description: the instanceId from ValidatorMetrics
required: true
schema:
type: string