@thanh01.pmt/curriculum-kit 1.0.8 → 1.0.9

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.
@@ -420,6 +420,32 @@ Guidelines:
420
420
  3. Keep technical terminology and official API symbols intact.
421
421
  4. Format output using clean Markdown, clear sections, bullet points, and code blocks where required.
422
422
  5. Do NOT use emojis in headings, tab titles, or UI navigation labels.`;
423
+ if (options.customInference) {
424
+ try {
425
+ const text = await options.customInference({
426
+ systemInstruction,
427
+ userPrompt: messages.map((m) => m.content).join("\n\n"),
428
+ messages,
429
+ temperature,
430
+ maxTokens,
431
+ onChunk: onChunk ?? (() => {
432
+ })
433
+ });
434
+ if (text && text.trim()) return text;
435
+ throw createAiInferenceError({
436
+ errorCode: "ERR_AI_ALL_PROVIDERS_FAILED",
437
+ message: "customInference returned empty output",
438
+ rawError: { customInference: "empty response" }
439
+ });
440
+ } catch (e) {
441
+ if (e?.errorCode || e?.name === "AiInferenceError") throw e;
442
+ throw createAiInferenceError({
443
+ errorCode: "ERR_AI_ALL_PROVIDERS_FAILED",
444
+ message: `customInference failed: ${e?.message || e}`,
445
+ rawError: { customInference: String(e?.message || e) }
446
+ });
447
+ }
448
+ }
423
449
  const formattedMessages = [
424
450
  { role: "system", content: systemInstruction },
425
451
  ...messages.map((m) => ({