File tree Expand file tree Collapse file tree
services/apps/members_enrichment_worker/src/activities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -327,7 +327,7 @@ export async function squashWorkExperiencesWithLLM(
327327 "startDate": "2020-06-01",
328328 "endDate": "2021-12-31",
329329 "source": "LinkedIn"
330- }
330+ },
331331 {
332332 "name": "Company Y",
333333 "title": "Manager",
@@ -338,8 +338,7 @@ export async function squashWorkExperiencesWithLLM(
338338 ]
339339
340340 Ensure the response is a **valid and complete JSON**.
341- DO NOT output anything else.
342- Output ONLY valid JSON
341+ Output ONLY valid JSON array. DO NOT output anything else.
343342 `
344343
345344 const llmService = new LlmService (
@@ -351,8 +350,15 @@ export async function squashWorkExperiencesWithLLM(
351350 svc . log ,
352351 )
353352
354- const result = await llmService . squashWorkExperiencesFromMultipleSources <
353+ const res = await llmService . squashWorkExperiencesFromMultipleSources <
355354 IMemberEnrichmentDataNormalizedOrganization [ ]
356355 > ( memberId , prompt )
357- return result . result
356+
357+ if ( ! Array . isArray ( res ?. result ) ) {
358+ const errorMessage = 'LLM returned invalid work experiences payload shape!'
359+ svc . log . warn ( { memberId, result : res ?. result } , errorMessage )
360+ throw new Error ( errorMessage )
361+ }
362+
363+ return res . result
358364}
You can’t perform that action at this time.
0 commit comments