@semiont/jobs 0.5.2 → 0.5.3
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 +13 -4
- package/dist/index.js +9 -162
- package/dist/index.js.map +1 -1
- package/dist/worker-main.js +10 -162
- package/dist/worker-main.js.map +1 -1
- package/package.json +1 -1
package/dist/worker-main.js
CHANGED
|
@@ -9804,159 +9804,6 @@ var MotivationParsers = class {
|
|
|
9804
9804
|
}
|
|
9805
9805
|
};
|
|
9806
9806
|
|
|
9807
|
-
// ../ontology/dist/index.js
|
|
9808
|
-
var TAG_SCHEMAS = {
|
|
9809
|
-
"legal-irac": {
|
|
9810
|
-
id: "legal-irac",
|
|
9811
|
-
name: "Legal Analysis (IRAC)",
|
|
9812
|
-
description: "Issue, Rule, Application, Conclusion framework for legal reasoning",
|
|
9813
|
-
domain: "legal",
|
|
9814
|
-
tags: [
|
|
9815
|
-
{
|
|
9816
|
-
name: "Issue",
|
|
9817
|
-
description: "The legal question or problem to be resolved",
|
|
9818
|
-
examples: [
|
|
9819
|
-
"What is the central legal question?",
|
|
9820
|
-
"What must the court decide?",
|
|
9821
|
-
"What is the dispute about?"
|
|
9822
|
-
]
|
|
9823
|
-
},
|
|
9824
|
-
{
|
|
9825
|
-
name: "Rule",
|
|
9826
|
-
description: "The relevant law, statute, or legal principle",
|
|
9827
|
-
examples: [
|
|
9828
|
-
"What law applies?",
|
|
9829
|
-
"What is the legal standard?",
|
|
9830
|
-
"What statute governs this case?"
|
|
9831
|
-
]
|
|
9832
|
-
},
|
|
9833
|
-
{
|
|
9834
|
-
name: "Application",
|
|
9835
|
-
description: "How the rule applies to the specific facts",
|
|
9836
|
-
examples: [
|
|
9837
|
-
"How does the law apply to these facts?",
|
|
9838
|
-
"Analysis of the case",
|
|
9839
|
-
"How do the facts satisfy the legal standard?"
|
|
9840
|
-
]
|
|
9841
|
-
},
|
|
9842
|
-
{
|
|
9843
|
-
name: "Conclusion",
|
|
9844
|
-
description: "The resolution or outcome based on the analysis",
|
|
9845
|
-
examples: [
|
|
9846
|
-
"What is the court's decision?",
|
|
9847
|
-
"What is the final judgment?",
|
|
9848
|
-
"What is the holding?"
|
|
9849
|
-
]
|
|
9850
|
-
}
|
|
9851
|
-
]
|
|
9852
|
-
},
|
|
9853
|
-
"scientific-imrad": {
|
|
9854
|
-
id: "scientific-imrad",
|
|
9855
|
-
name: "Scientific Paper (IMRAD)",
|
|
9856
|
-
description: "Introduction, Methods, Results, Discussion structure for research papers",
|
|
9857
|
-
domain: "scientific",
|
|
9858
|
-
tags: [
|
|
9859
|
-
{
|
|
9860
|
-
name: "Introduction",
|
|
9861
|
-
description: "Background, context, and research question",
|
|
9862
|
-
examples: [
|
|
9863
|
-
"What is the research question?",
|
|
9864
|
-
"Why is this important?",
|
|
9865
|
-
"What is the hypothesis?"
|
|
9866
|
-
]
|
|
9867
|
-
},
|
|
9868
|
-
{
|
|
9869
|
-
name: "Methods",
|
|
9870
|
-
description: "Experimental design and procedures",
|
|
9871
|
-
examples: [
|
|
9872
|
-
"How was the study conducted?",
|
|
9873
|
-
"What methods were used?",
|
|
9874
|
-
"What was the experimental design?"
|
|
9875
|
-
]
|
|
9876
|
-
},
|
|
9877
|
-
{
|
|
9878
|
-
name: "Results",
|
|
9879
|
-
description: "Findings and observations",
|
|
9880
|
-
examples: [
|
|
9881
|
-
"What did the study find?",
|
|
9882
|
-
"What are the data?",
|
|
9883
|
-
"What were the observations?"
|
|
9884
|
-
]
|
|
9885
|
-
},
|
|
9886
|
-
{
|
|
9887
|
-
name: "Discussion",
|
|
9888
|
-
description: "Interpretation and implications of results",
|
|
9889
|
-
examples: [
|
|
9890
|
-
"What do the results mean?",
|
|
9891
|
-
"What are the implications?",
|
|
9892
|
-
"How do these findings relate to prior work?"
|
|
9893
|
-
]
|
|
9894
|
-
}
|
|
9895
|
-
]
|
|
9896
|
-
},
|
|
9897
|
-
"argument-toulmin": {
|
|
9898
|
-
id: "argument-toulmin",
|
|
9899
|
-
name: "Argument Structure (Toulmin)",
|
|
9900
|
-
description: "Claim, Evidence, Warrant, Counterargument, Rebuttal framework for argumentation",
|
|
9901
|
-
domain: "general",
|
|
9902
|
-
tags: [
|
|
9903
|
-
{
|
|
9904
|
-
name: "Claim",
|
|
9905
|
-
description: "The main assertion or thesis",
|
|
9906
|
-
examples: [
|
|
9907
|
-
"What is being argued?",
|
|
9908
|
-
"What is the main point?",
|
|
9909
|
-
"What position is being taken?"
|
|
9910
|
-
]
|
|
9911
|
-
},
|
|
9912
|
-
{
|
|
9913
|
-
name: "Evidence",
|
|
9914
|
-
description: "Data or facts supporting the claim",
|
|
9915
|
-
examples: [
|
|
9916
|
-
"What supports this claim?",
|
|
9917
|
-
"What are the facts?",
|
|
9918
|
-
"What data is provided?"
|
|
9919
|
-
]
|
|
9920
|
-
},
|
|
9921
|
-
{
|
|
9922
|
-
name: "Warrant",
|
|
9923
|
-
description: "Reasoning connecting evidence to claim",
|
|
9924
|
-
examples: [
|
|
9925
|
-
"Why does this evidence support the claim?",
|
|
9926
|
-
"What is the logic?",
|
|
9927
|
-
"How does this reasoning work?"
|
|
9928
|
-
]
|
|
9929
|
-
},
|
|
9930
|
-
{
|
|
9931
|
-
name: "Counterargument",
|
|
9932
|
-
description: "Opposing viewpoints or objections",
|
|
9933
|
-
examples: [
|
|
9934
|
-
"What are the objections?",
|
|
9935
|
-
"What do critics say?",
|
|
9936
|
-
"What are alternative views?"
|
|
9937
|
-
]
|
|
9938
|
-
},
|
|
9939
|
-
{
|
|
9940
|
-
name: "Rebuttal",
|
|
9941
|
-
description: "Response to counterarguments",
|
|
9942
|
-
examples: [
|
|
9943
|
-
"How is the objection addressed?",
|
|
9944
|
-
"Why is the counterargument wrong?",
|
|
9945
|
-
"How is the criticism answered?"
|
|
9946
|
-
]
|
|
9947
|
-
}
|
|
9948
|
-
]
|
|
9949
|
-
}
|
|
9950
|
-
};
|
|
9951
|
-
function getTagSchema(schemaId) {
|
|
9952
|
-
return TAG_SCHEMAS[schemaId] || null;
|
|
9953
|
-
}
|
|
9954
|
-
function getSchemaCategory(schemaId, categoryName) {
|
|
9955
|
-
const schema = getTagSchema(schemaId);
|
|
9956
|
-
if (!schema) return null;
|
|
9957
|
-
return schema.tags.find((tag) => tag.name === categoryName) || null;
|
|
9958
|
-
}
|
|
9959
|
-
|
|
9960
9807
|
// src/workers/annotation-detection.ts
|
|
9961
9808
|
var AnnotationDetection = class {
|
|
9962
9809
|
/**
|
|
@@ -10014,19 +9861,19 @@ var AnnotationDetection = class {
|
|
|
10014
9861
|
/**
|
|
10015
9862
|
* Detect tags in content for a specific category.
|
|
10016
9863
|
*
|
|
9864
|
+
* The full `TagSchema` is supplied by the dispatcher (resolved against
|
|
9865
|
+
* the per-KB tag-schema projection at job-creation time) so the worker
|
|
9866
|
+
* is independent of the registry.
|
|
9867
|
+
*
|
|
10017
9868
|
* `sourceLanguage` is the locale of the content being analyzed. Body-locale
|
|
10018
9869
|
* (`language`) doesn't influence the tag prompt — categories are schema
|
|
10019
9870
|
* identifiers, not LLM-generated text — so it's consumed at the body-stamp
|
|
10020
9871
|
* site, not here.
|
|
10021
9872
|
*/
|
|
10022
|
-
static async detectTags(content, client,
|
|
10023
|
-
const
|
|
10024
|
-
if (!schema) {
|
|
10025
|
-
throw new Error(`Invalid tag schema: ${schemaId}`);
|
|
10026
|
-
}
|
|
10027
|
-
const categoryInfo = getSchemaCategory(schemaId, category);
|
|
9873
|
+
static async detectTags(content, client, schema, category, sourceLanguage) {
|
|
9874
|
+
const categoryInfo = schema.tags.find((t) => t.name === category);
|
|
10028
9875
|
if (!categoryInfo) {
|
|
10029
|
-
throw new Error(`Invalid category "${category}" for schema ${
|
|
9876
|
+
throw new Error(`Invalid category "${category}" for schema ${schema.id}`);
|
|
10030
9877
|
}
|
|
10031
9878
|
const prompt = MotivationPrompts.buildTagPrompt(
|
|
10032
9879
|
content,
|
|
@@ -10548,7 +10395,7 @@ async function processTagJob(content, inferenceClient, params, userId, generator
|
|
|
10548
10395
|
const categoryTags = await AnnotationDetection.detectTags(
|
|
10549
10396
|
content,
|
|
10550
10397
|
inferenceClient,
|
|
10551
|
-
params.
|
|
10398
|
+
params.schema,
|
|
10552
10399
|
category,
|
|
10553
10400
|
params.sourceLanguage
|
|
10554
10401
|
);
|
|
@@ -10563,7 +10410,7 @@ async function processTagJob(content, inferenceClient, params, userId, generator
|
|
|
10563
10410
|
byCategory[category] = (byCategory[category] ?? 0) + 1;
|
|
10564
10411
|
return buildTextAnnotation(params.resourceId, userId, generator, "tagging", t, [
|
|
10565
10412
|
{ type: "TextualBody", value: category, purpose: "tagging", format: "text/plain", language: bodyLanguage },
|
|
10566
|
-
{ type: "TextualBody", value: params.
|
|
10413
|
+
{ type: "TextualBody", value: params.schema.id, purpose: "classifying", format: "text/plain" }
|
|
10567
10414
|
]);
|
|
10568
10415
|
});
|
|
10569
10416
|
onProgress(100, `Complete! Created ${annotations.length} tags`, "creating");
|
|
@@ -10804,6 +10651,7 @@ async function handleJobInner(adapter, config, job) {
|
|
|
10804
10651
|
...genParams.referenceId ? { sourceAnnotationId: genParams.referenceId } : {},
|
|
10805
10652
|
...genParams.prompt ? { generationPrompt: genParams.prompt } : {},
|
|
10806
10653
|
...genParams.language ? { language: genParams.language } : {},
|
|
10654
|
+
...genParams.entityTypes && genParams.entityTypes.length > 0 ? { entityTypes: genParams.entityTypes } : {},
|
|
10807
10655
|
generator
|
|
10808
10656
|
});
|
|
10809
10657
|
await emitEvent(session, "job:complete", {
|