@@ -75,6 +75,9 @@ interface CaseByProfoundPromptId {
7575 expected : string ;
7676 tags : string [ ] ;
7777 caseId : ObjectId ;
78+ metadata : {
79+ category : string ;
80+ }
7881 } ;
7982}
8083const casesByPromptId = async (
@@ -86,6 +89,7 @@ const casesByPromptId = async (
8689 expected : doc . expected ,
8790 tags : doc . tags ,
8891 caseId : doc . _id ,
92+ metadata : doc . metadata ,
8993 } ;
9094 return map ;
9195 } , { } as CaseByProfoundPromptId ) ;
@@ -189,6 +193,7 @@ export const main = async (startDateArg?: string, endDateArg?: string) => {
189193 } ;
190194 const referenceAlignmentFn = makeReferenceAlignment ( openAiClient , config ) ;
191195 const answerRecords : any [ ] = [ ] ;
196+ const promptsWithNoAssociatedCase = new Set ( )
192197 const { results, errors } = await PromisePool . for ( answers )
193198 . withConcurrency ( model . maxConcurrency ?? 5 )
194199 . process ( async ( currentAnswer ) => {
@@ -204,7 +209,7 @@ export const main = async (startDateArg?: string, endDateArg?: string) => {
204209 const currentPromptId = currentAnswer . prompt_id ;
205210 const currentCase = casesByPromptMap [ currentPromptId ] ;
206211 if ( ! currentCase ) {
207- console . log ( `No case found for ${ currentPrompt } `) ;
212+ promptsWithNoAssociatedCase . add ( ` ${ currentPromptId } - ${ currentPrompt } `) ;
208213 }
209214
210215 // calculate reference alignment score
@@ -239,8 +244,8 @@ export const main = async (startDateArg?: string, endDateArg?: string) => {
239244 } catch ( err ) {
240245 console . error ( "Error in referenceAlignmentFn:" , {
241246 prompt : currentAnswer . prompt ,
242- response : currentAnswer . response ,
243- expected : currentCase ?. expected ,
247+ profoundPromptId : currentAnswer . prompt_id ,
248+ profoundRunId : currentAnswer . run_id ,
244249 error : err ,
245250 } ) ;
246251 referenceAlignment = {
@@ -283,12 +288,17 @@ export const main = async (startDateArg?: string, endDateArg?: string) => {
283288 expectedResponse : currentCase ?. expected ,
284289 profoundPromptId : currentAnswer . prompt_id ,
285290 profoundRunId : currentAnswer . run_id ,
286- dataset : currentCase ? getDataset ( currentCase . tags , datasetsByTagMap ) : null
291+ dataset : currentCase ? getDataset ( currentCase . tags , datasetsByTagMap ) : null ,
292+ category : currentCase ? currentCase . metadata . category : null
287293 } ;
288294 answerRecords . push ( answerEngineRecord ) ;
289295 return answerEngineRecord ;
290296 } ) ;
291297
298+ console . log ( `Found ${ promptsWithNoAssociatedCase . size } prompts with no associated case:` )
299+ promptsWithNoAssociatedCase . forEach ( ( promptInfo : any ) => {
300+ console . log ( ` - ${ promptInfo } ` ) ;
301+ } ) ;
292302 // update the llm_answers collection
293303 if ( answerRecords . length > 0 ) {
294304 const bulkOps = answerRecords . map ( ( record ) => ( {
@@ -306,7 +316,7 @@ export const main = async (startDateArg?: string, endDateArg?: string) => {
306316 const inserted = result . upsertedCount || 0 ;
307317 const updated = result . modifiedCount || 0 ;
308318 console . log (
309- `BulkWrite to llm_answers collection completed: ${ inserted } inserted, ${ updated } updated (out of ${ answerRecords . length } records).`
319+ `BulkWrite to llm_answers collection completed: ${ inserted } inserted, ${ updated } updated (out of ${ answerRecords . length } records between ${ start . toISOString ( ) } and ${ end . toISOString ( ) } ).`
310320 ) ;
311321 } catch ( err ) {
312322 console . error ( "BulkWrite to llm_answers collection failed:" , err ) ;
0 commit comments