Skip to content

Commit

Permalink
Updating catch for guardrails (#1631) (#1633)
Browse files Browse the repository at this point in the history
* updating catch for guardrails



* removing osd config



* removing dismissible tag



---------


(cherry picked from commit 79faaeb)

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 48646fd commit 0e6dd62
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/constants/query_assist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export const QUERY_ASSIST_API = {

export const ML_COMMONS_API_PREFIX = '/_plugins/_ml';

export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrail triggered' };
export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrails triggered' };
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const prohibitedQueryCallOut = (
size="s"
color="danger"
iconType="alert"
dismissible
/>
);

Expand All @@ -106,7 +105,6 @@ const emptyQueryCallOut = (
size="s"
color="warning"
iconType="iInCircle"
dismissible
/>
);

Expand All @@ -117,7 +115,6 @@ const pplGenerated = (
size="s"
color="success"
iconType="check"
dismissible
/>
);

Expand Down Expand Up @@ -200,7 +197,7 @@ export const QueryAssistInput: React.FC<React.PropsWithChildren<Props>> = (props
} as Error;
if (
error.body.statusCode === 400 &&
error.body.message === ERROR_DETAILS.GUARDRAILS_TRIGGERED
error.body.message.includes(ERROR_DETAILS.GUARDRAILS_TRIGGERED)
)
return new ProhibitedQueryError(error.body.message);
return error.body as Error;
Expand Down
4 changes: 2 additions & 2 deletions server/routes/query_assist/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function registerQueryAssistRoutes(router: IRouter) {
if (
isResponseError(error) &&
error.statusCode === 400 &&
error.body.error.details === ERROR_DETAILS.GUARDRAILS_TRIGGERED
error.body.includes(ERROR_DETAILS.GUARDRAILS_TRIGGERED)
) {
return response.badRequest({ body: ERROR_DETAILS.GUARDRAILS_TRIGGERED });
}
Expand Down Expand Up @@ -156,7 +156,7 @@ export function registerQueryAssistRoutes(router: IRouter) {
if (
isResponseError(error) &&
error.statusCode === 400 &&
error.body.error.details === ERROR_DETAILS.GUARDRAILS_TRIGGERED
error.body.includes(ERROR_DETAILS.GUARDRAILS_TRIGGERED)
) {
return response.badRequest({ body: ERROR_DETAILS.GUARDRAILS_TRIGGERED });
}
Expand Down

0 comments on commit 0e6dd62

Please sign in to comment.