From b23db23ebf991894560761d9bad2dd81d3d38f93 Mon Sep 17 00:00:00 2001 From: visargD Date: Thu, 29 Aug 2024 20:59:50 +0530 Subject: [PATCH 1/2] chore: update patronus response schema based on its field deprecation notice --- plugins/aporia/validateProject.ts | 2 +- plugins/patronus/custom.ts | 6 +++--- plugins/patronus/isConcise.ts | 6 +++--- plugins/patronus/isHelpful.ts | 6 +++--- plugins/patronus/isPolite.ts | 6 +++--- plugins/patronus/noApologies.ts | 6 +++--- plugins/patronus/noGenderBias.ts | 6 +++--- plugins/patronus/noRacialBias.ts | 6 +++--- plugins/patronus/phi.ts | 6 +++--- plugins/patronus/pii.ts | 6 +++--- plugins/patronus/retrievalAnswerRelevance.ts | 6 +++--- plugins/patronus/toxicity.ts | 6 +++--- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/plugins/aporia/validateProject.ts b/plugins/aporia/validateProject.ts index f059d9cf..17342ad4 100644 --- a/plugins/aporia/validateProject.ts +++ b/plugins/aporia/validateProject.ts @@ -32,7 +32,7 @@ export const handler: PluginHandler = async ( try { const aporiaObject: any = { - messages: context.request?.messages, + messages: context.request?.json?.messages, explain: true, }; diff --git a/plugins/patronus/custom.ts b/plugins/patronus/custom.ts index 698ae073..37dd530e 100644 --- a/plugins/patronus/custom.ts +++ b/plugins/patronus/custom.ts @@ -45,10 +45,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/isConcise.ts b/plugins/patronus/isConcise.ts index ebab9cf5..c62c471c 100644 --- a/plugins/patronus/isConcise.ts +++ b/plugins/patronus/isConcise.ts @@ -45,10 +45,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/isHelpful.ts b/plugins/patronus/isHelpful.ts index 427c8ef2..1f416384 100644 --- a/plugins/patronus/isHelpful.ts +++ b/plugins/patronus/isHelpful.ts @@ -45,10 +45,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/isPolite.ts b/plugins/patronus/isPolite.ts index 099fc29a..25a92378 100644 --- a/plugins/patronus/isPolite.ts +++ b/plugins/patronus/isPolite.ts @@ -45,10 +45,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/noApologies.ts b/plugins/patronus/noApologies.ts index 42dd13ed..924ce283 100644 --- a/plugins/patronus/noApologies.ts +++ b/plugins/patronus/noApologies.ts @@ -45,10 +45,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/noGenderBias.ts b/plugins/patronus/noGenderBias.ts index 96357668..9a956aad 100644 --- a/plugins/patronus/noGenderBias.ts +++ b/plugins/patronus/noGenderBias.ts @@ -45,10 +45,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/noRacialBias.ts b/plugins/patronus/noRacialBias.ts index 173e40a2..c21deaa4 100644 --- a/plugins/patronus/noRacialBias.ts +++ b/plugins/patronus/noRacialBias.ts @@ -45,10 +45,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/phi.ts b/plugins/patronus/phi.ts index fb713261..2c62e788 100644 --- a/plugins/patronus/phi.ts +++ b/plugins/patronus/phi.ts @@ -42,10 +42,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/pii.ts b/plugins/patronus/pii.ts index 746b81f7..4495788b 100644 --- a/plugins/patronus/pii.ts +++ b/plugins/patronus/pii.ts @@ -42,10 +42,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/retrievalAnswerRelevance.ts b/plugins/patronus/retrievalAnswerRelevance.ts index 283fbd26..c3b353d8 100644 --- a/plugins/patronus/retrievalAnswerRelevance.ts +++ b/plugins/patronus/retrievalAnswerRelevance.ts @@ -43,10 +43,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; diff --git a/plugins/patronus/toxicity.ts b/plugins/patronus/toxicity.ts index 90601f1f..ab3f8331 100644 --- a/plugins/patronus/toxicity.ts +++ b/plugins/patronus/toxicity.ts @@ -42,10 +42,10 @@ export const handler: PluginHandler = async ( const evalResult = result.results[0]; error = evalResult.error_message; - // verdict is true if evalResult.result.pass is 1 - verdict = evalResult.result.pass === 1; + // verdict can be true/false + verdict = evalResult.evaluation_result.pass; - data = evalResult.result.additional_info; + data = evalResult.evaluation_result.additional_info; } catch (e: any) { delete e.stack; error = e; From ba6eb5cd1176df04cc578359103627bf5fee780a Mon Sep 17 00:00:00 2001 From: visargD Date: Thu, 29 Aug 2024 21:15:38 +0530 Subject: [PATCH 2/2] chore: revert aporia fix --- plugins/aporia/validateProject.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aporia/validateProject.ts b/plugins/aporia/validateProject.ts index 17342ad4..f059d9cf 100644 --- a/plugins/aporia/validateProject.ts +++ b/plugins/aporia/validateProject.ts @@ -32,7 +32,7 @@ export const handler: PluginHandler = async ( try { const aporiaObject: any = { - messages: context.request?.json?.messages, + messages: context.request?.messages, explain: true, };