@@ -4,11 +4,11 @@ import { chatCompletionObject } from "@/utils/llms";
44import { stringifyEmail } from "@/utils/stringify-email" ;
55import type { EmailForLLM } from "@/utils/types" ;
66import { createScopedLogger } from "@/utils/logger" ;
7- import { Braintrust } from "@/utils/braintrust" ;
7+ // import { Braintrust } from "@/utils/braintrust";
88
99const logger = createScopedLogger ( "ai-choose-rule" ) ;
1010
11- const braintrust = new Braintrust ( "choose-rule-2" ) ;
11+ // const braintrust = new Braintrust("choose-rule-2");
1212
1313type GetAiResponseOptions = {
1414 email : EmailForLLM ;
@@ -98,7 +98,7 @@ ${emailSection}
9898 ] ,
9999 schema : z . object ( {
100100 reason : z . string ( ) ,
101- ruleName : z . string ( ) ,
101+ ruleName : z . string ( ) . nullish ( ) ,
102102 noMatchFound : z . boolean ( ) . nullish ( ) ,
103103 } ) ,
104104 userEmail : emailAccount . email ,
@@ -107,20 +107,20 @@ ${emailSection}
107107
108108 logger . trace ( "Response" , aiResponse . object ) ;
109109
110- braintrust . insertToDataset ( {
111- id : email . id ,
112- input : {
113- email : emailSection ,
114- rules : rules . map ( ( rule ) => ( {
115- name : rule . name ,
116- instructions : rule . instructions ,
117- } ) ) ,
118- hasAbout : ! ! emailAccount . about ,
119- userAbout : emailAccount . about ,
120- userEmail : emailAccount . email ,
121- } ,
122- expected : aiResponse . object . ruleName ,
123- } ) ;
110+ // braintrust.insertToDataset({
111+ // id: email.id,
112+ // input: {
113+ // email: emailSection,
114+ // rules: rules.map((rule) => ({
115+ // name: rule.name,
116+ // instructions: rule.instructions,
117+ // })),
118+ // hasAbout: !!emailAccount.about,
119+ // userAbout: emailAccount.about,
120+ // userEmail: emailAccount.email,
121+ // },
122+ // expected: aiResponse.object.ruleName,
123+ // });
124124
125125 return aiResponse . object ;
126126}
@@ -149,7 +149,8 @@ export async function aiChooseRule<
149149
150150 const selectedRule = aiResponse . ruleName
151151 ? rules . find (
152- ( rule ) => rule . name . toLowerCase ( ) === aiResponse . ruleName . toLowerCase ( ) ,
152+ ( rule ) =>
153+ rule . name . toLowerCase ( ) === aiResponse . ruleName ?. toLowerCase ( ) ,
153154 )
154155 : undefined ;
155156
0 commit comments