Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions services/apps/members_enrichment_worker/src/activities/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ export async function squashWorkExperiencesWithLLM(
Maintain all relevant data fields in the final timeline and ensure no essential information is lost.

Output Format:
Return a single array of IMemberEnrichmentDataNormalizedOrganization objects:
Return a single array of IMemberEnrichmentDataNormalizedOrganization objects.
Each element must be a JSON object, never a JSON-encoded string.

Input Example:
[
Expand Down Expand Up @@ -358,7 +359,10 @@ export async function squashWorkExperiencesWithLLM(
IMemberEnrichmentDataNormalizedOrganization[]
>(memberId, prompt)

if (!Array.isArray(res?.result)) {
if (
!Array.isArray(res?.result) ||
!res.result.every((we) => _.isPlainObject(we) && typeof we.name === 'string')
) {
const errorMessage = 'LLM returned invalid work experiences payload shape!'
svc.log.warn({ memberId, result: res?.result }, errorMessage)
throw new Error(errorMessage)
Expand Down
Loading