@semiont/jobs 0.5.23 → 0.5.25
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.d.ts +15 -20
- package/dist/index.js +364 -111
- package/dist/index.js.map +1 -1
- package/dist/worker-main.js +523 -196
- package/dist/worker-main.js.map +1 -1
- package/package.json +10 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JobId, UserId, ResourceId, EntityType, AnnotationId, GatheredContext, SupportedMediaType, TagSchema, Logger, EventBus, components } from '@semiont/core';
|
|
1
|
+
import { JobId, UserId, ResourceId, EntityType, AnnotationId, GatheredContext, SupportedMediaType, TagSchema, Logger, EventBus, components, Annotation } from '@semiont/core';
|
|
2
2
|
import { SemiontProject } from '@semiont/core/node';
|
|
3
3
|
import { InferenceClient } from '@semiont/inference';
|
|
4
4
|
|
|
@@ -524,17 +524,6 @@ interface GenerationCitation {
|
|
|
524
524
|
exact: string;
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
-
/**
|
|
528
|
-
* Job Processors
|
|
529
|
-
*
|
|
530
|
-
* Pure functions that take content + inference client + params,
|
|
531
|
-
* report progress via callback, and return annotations + results.
|
|
532
|
-
*
|
|
533
|
-
* No EventBus, no JobQueue, no side effects except calling inference.
|
|
534
|
-
* Driven by the remote worker process (worker-process.ts), which claims
|
|
535
|
-
* jobs over SSE and dispatches by jobType to these functions.
|
|
536
|
-
*/
|
|
537
|
-
|
|
538
527
|
/** A detected span — offsets into the extracted `.text`, plus optional context. */
|
|
539
528
|
type SpanMatch = {
|
|
540
529
|
exact: string;
|
|
@@ -550,7 +539,7 @@ type SpanMatch = {
|
|
|
550
539
|
* motivation-specific body. This is the single axis that varies by media type,
|
|
551
540
|
* so the detection processors themselves stay media-agnostic.
|
|
552
541
|
*/
|
|
553
|
-
type BuildAnnotation = (motivation:
|
|
542
|
+
type BuildAnnotation = (motivation: Motivation, match: SpanMatch, body?: Annotation['body']) => Annotation;
|
|
554
543
|
/**
|
|
555
544
|
* Progress callback. The three positional args satisfy the minimum
|
|
556
545
|
* `JobProgress` required fields (`percentage`, `message`, `stage`).
|
|
@@ -560,8 +549,11 @@ type BuildAnnotation = (motivation: string, match: SpanMatch, body?: Record<stri
|
|
|
560
549
|
*/
|
|
561
550
|
type OnProgress = (percentage: number, message: string, stage: string, extra?: Partial<JobProgress>) => void;
|
|
562
551
|
type JobProgress = components['schemas']['JobProgress'];
|
|
552
|
+
/** The five W3C motivations this system mints — a closed vocabulary, so it is
|
|
553
|
+
* typed as one rather than as `string`. */
|
|
554
|
+
type Motivation = Annotation['motivation'];
|
|
563
555
|
interface ProcessorResult<R> {
|
|
564
|
-
annotations:
|
|
556
|
+
annotations: Annotation[];
|
|
565
557
|
result: R;
|
|
566
558
|
}
|
|
567
559
|
declare function processHighlightJob(content: string, inferenceClient: InferenceClient, params: HighlightDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress): Promise<ProcessorResult<HighlightDetectionResult>>;
|
|
@@ -570,7 +562,7 @@ declare function processAssessmentJob(content: string, inferenceClient: Inferenc
|
|
|
570
562
|
declare function processReferenceJob(content: string, inferenceClient: InferenceClient, params: DetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress, logger: Logger): Promise<ProcessorResult<DetectionResult>>;
|
|
571
563
|
declare function processTagJob(content: string, inferenceClient: InferenceClient, params: TagDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress): Promise<ProcessorResult<TagDetectionResult>>;
|
|
572
564
|
declare function processGenerationJob(inferenceClient: InferenceClient, params: GenerationParams, onProgress: OnProgress, logger: Logger): Promise<{
|
|
573
|
-
content:
|
|
565
|
+
content: Uint8Array;
|
|
574
566
|
title: string;
|
|
575
567
|
format: SupportedMediaType;
|
|
576
568
|
citations: GenerationCitation[];
|
|
@@ -652,7 +644,7 @@ declare class AnnotationDetection {
|
|
|
652
644
|
* (source-resource locale). See `types.ts` "Locale conventions" for the
|
|
653
645
|
* full discussion.
|
|
654
646
|
*/
|
|
655
|
-
static detectComments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): Promise<CommentMatch[]>;
|
|
647
|
+
static detectComments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<CommentMatch[]>;
|
|
656
648
|
/**
|
|
657
649
|
* Detect highlights in content.
|
|
658
650
|
*
|
|
@@ -660,7 +652,7 @@ declare class AnnotationDetection {
|
|
|
660
652
|
* applies, used in the prompt so the LLM analyzes non-English source
|
|
661
653
|
* correctly.
|
|
662
654
|
*/
|
|
663
|
-
static detectHighlights(content: string, client: InferenceClient, instructions?: string, density?: number, sourceLanguage?: string): Promise<HighlightMatch[]>;
|
|
655
|
+
static detectHighlights(content: string, client: InferenceClient, instructions?: string, density?: number, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<HighlightMatch[]>;
|
|
664
656
|
/**
|
|
665
657
|
* Detect assessments in content.
|
|
666
658
|
*
|
|
@@ -668,7 +660,7 @@ declare class AnnotationDetection {
|
|
|
668
660
|
* (annotation body locale). `sourceLanguage` is the locale of the content
|
|
669
661
|
* being analyzed (source-resource locale).
|
|
670
662
|
*/
|
|
671
|
-
static detectAssessments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): Promise<AssessmentMatch[]>;
|
|
663
|
+
static detectAssessments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<AssessmentMatch[]>;
|
|
672
664
|
/**
|
|
673
665
|
* Detect tags in content for a specific category.
|
|
674
666
|
*
|
|
@@ -681,7 +673,7 @@ declare class AnnotationDetection {
|
|
|
681
673
|
* identifiers, not LLM-generated text — so it's consumed at the body-stamp
|
|
682
674
|
* site, not here.
|
|
683
675
|
*/
|
|
684
|
-
static detectTags(content: string, client: InferenceClient, schema: TagSchema, category: string, sourceLanguage?: string): Promise<TagMatch[]>;
|
|
676
|
+
static detectTags(content: string, client: InferenceClient, schema: TagSchema, category: string, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<TagMatch[]>;
|
|
685
677
|
}
|
|
686
678
|
|
|
687
679
|
/**
|
|
@@ -701,7 +693,10 @@ declare class AnnotationDetection {
|
|
|
701
693
|
* generate German content from an English source resource. See
|
|
702
694
|
* `types.ts` "Locale conventions" for the full discussion.
|
|
703
695
|
*/
|
|
704
|
-
declare function generateResourceFromTopic(topic: string, entityTypes: string[], client: InferenceClient, logger: Logger, userPrompt?: string, locale?: string, context?: GatheredContext, temperature?: number, maxTokens?: number, sourceLanguage?: string, outputMediaType?: SupportedMediaType, task?: string, structure?: string, cite?: boolean
|
|
696
|
+
declare function generateResourceFromTopic(topic: string, entityTypes: string[], client: InferenceClient, logger: Logger, userPrompt?: string, locale?: string, context?: GatheredContext, temperature?: number, maxTokens?: number, sourceLanguage?: string, outputMediaType?: SupportedMediaType, task?: string, structure?: string, cite?: boolean, repair?: {
|
|
697
|
+
source: string;
|
|
698
|
+
error: string;
|
|
699
|
+
}): Promise<{
|
|
705
700
|
title: string;
|
|
706
701
|
content: string;
|
|
707
702
|
}>;
|