@semiont/jobs 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1183,10 +1183,19 @@ Knowledge graph context:
1183
1183
  ${parts.join("\n")}`;
1184
1184
  }
1185
1185
  }
1186
+ let semanticContextSection = "";
1187
+ const similar = context?.semanticContext?.similar ?? [];
1188
+ if (similar.length > 0) {
1189
+ const lines = [...similar].sort((a, b) => b.score - a.score).slice(0, 3).map((m) => `- (${m.score.toFixed(2)}) ${m.text.slice(0, 240)}`);
1190
+ semanticContextSection = `
1191
+
1192
+ Related passages from the knowledge base:
1193
+ ${lines.join("\n")}`;
1194
+ }
1186
1195
  const structureGuidance = finalMaxTokens >= 1e3 ? "organized into titled sections (## Section) with well-structured paragraphs" : "organized into well-structured paragraphs";
1187
1196
  const prompt = `Generate a concise, informative resource about "${topic}".
1188
1197
  ${entityTypes.length > 0 ? `Focus on these entity types: ${entityTypes.join(", ")}.` : ""}
1189
- ${userPrompt ? `Additional context: ${userPrompt}` : ""}${annotationSection}${contextSection}${graphContextSection}${sourceLanguageInstruction}${languageInstruction}
1198
+ ${userPrompt ? `Additional context: ${userPrompt}` : ""}${annotationSection}${contextSection}${graphContextSection}${semanticContextSection}${sourceLanguageInstruction}${languageInstruction}
1190
1199
 
1191
1200
  Requirements:
1192
1201
  - Start with a clear heading (# Title)