@llm-jury/core 0.1.0
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/README.md +378 -0
- package/dist/calibration/index.d.ts +1 -0
- package/dist/calibration/index.js +1 -0
- package/dist/calibration/optimizer.d.ts +26 -0
- package/dist/calibration/optimizer.js +61 -0
- package/dist/classifiers/base.d.ts +11 -0
- package/dist/classifiers/base.js +7 -0
- package/dist/classifiers/functionAdapter.d.ts +8 -0
- package/dist/classifiers/functionAdapter.js +20 -0
- package/dist/classifiers/huggingFaceAdapter.d.ts +20 -0
- package/dist/classifiers/huggingFaceAdapter.js +52 -0
- package/dist/classifiers/index.d.ts +5 -0
- package/dist/classifiers/index.js +5 -0
- package/dist/classifiers/llmClassifier.d.ts +19 -0
- package/dist/classifiers/llmClassifier.js +47 -0
- package/dist/classifiers/sklearnAdapter.d.ts +14 -0
- package/dist/classifiers/sklearnAdapter.js +29 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/main.d.ts +4 -0
- package/dist/cli/main.js +261 -0
- package/dist/debate/engine.d.ts +48 -0
- package/dist/debate/engine.js +309 -0
- package/dist/debate/index.d.ts +1 -0
- package/dist/debate/index.js +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/judges/base.d.ts +16 -0
- package/dist/judges/base.js +1 -0
- package/dist/judges/bayesian.d.ts +8 -0
- package/dist/judges/bayesian.js +52 -0
- package/dist/judges/index.d.ts +5 -0
- package/dist/judges/index.js +5 -0
- package/dist/judges/llmJudge.d.ts +19 -0
- package/dist/judges/llmJudge.js +86 -0
- package/dist/judges/majorityVote.d.ts +5 -0
- package/dist/judges/majorityVote.js +45 -0
- package/dist/judges/weightedVote.d.ts +5 -0
- package/dist/judges/weightedVote.js +42 -0
- package/dist/jury/core.d.ts +43 -0
- package/dist/jury/core.js +113 -0
- package/dist/jury/index.d.ts +1 -0
- package/dist/jury/index.js +1 -0
- package/dist/llm/client.d.ts +23 -0
- package/dist/llm/client.js +85 -0
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.js +1 -0
- package/dist/personas/base.d.ts +19 -0
- package/dist/personas/base.js +1 -0
- package/dist/personas/index.d.ts +2 -0
- package/dist/personas/index.js +2 -0
- package/dist/personas/registry.d.ts +8 -0
- package/dist/personas/registry.js +83 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +23 -0
- package/package.json +43 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function persona(p) {
|
|
2
|
+
return {
|
|
3
|
+
model: "gpt-5-mini",
|
|
4
|
+
temperature: 0.3,
|
|
5
|
+
...p,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export class PersonaRegistry {
|
|
9
|
+
static contentModeration() {
|
|
10
|
+
return [
|
|
11
|
+
persona({
|
|
12
|
+
name: "Policy Analyst",
|
|
13
|
+
role: "Interprets content against platform policies",
|
|
14
|
+
systemPrompt: "You are a content policy analyst. Focus on explicit policy violations, edge cases in policy language, and precedent from similar decisions.",
|
|
15
|
+
knownBias: "policy-strict",
|
|
16
|
+
}),
|
|
17
|
+
persona({
|
|
18
|
+
name: "Cultural Context Expert",
|
|
19
|
+
role: "Considers cultural and contextual nuances",
|
|
20
|
+
systemPrompt: "You are an expert in cross-cultural communication and context. Consider satire, community norms, and linguistic register.",
|
|
21
|
+
knownBias: "tends permissive on context",
|
|
22
|
+
}),
|
|
23
|
+
persona({
|
|
24
|
+
name: "Harm Assessment Specialist",
|
|
25
|
+
role: "Evaluates potential real-world impact",
|
|
26
|
+
systemPrompt: "You evaluate potential real-world harm and impact on vulnerable groups.",
|
|
27
|
+
knownBias: "harm-focused",
|
|
28
|
+
}),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
static legalCompliance() {
|
|
32
|
+
return [
|
|
33
|
+
persona({
|
|
34
|
+
name: "Regulatory Attorney",
|
|
35
|
+
role: "Strict legal interpretation",
|
|
36
|
+
systemPrompt: "You are a regulatory compliance attorney.",
|
|
37
|
+
}),
|
|
38
|
+
persona({
|
|
39
|
+
name: "Business Risk Analyst",
|
|
40
|
+
role: "Weighs legal risk against business impact",
|
|
41
|
+
systemPrompt: "You are a business risk analyst.",
|
|
42
|
+
}),
|
|
43
|
+
persona({
|
|
44
|
+
name: "Industry Standards Expert",
|
|
45
|
+
role: "Compares against industry norms",
|
|
46
|
+
systemPrompt: "You are an expert in industry standards.",
|
|
47
|
+
}),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
static medicalTriage() {
|
|
51
|
+
return [
|
|
52
|
+
persona({
|
|
53
|
+
name: "Clinical Safety Reviewer",
|
|
54
|
+
role: "Prioritizes patient safety and urgency",
|
|
55
|
+
systemPrompt: "You are a clinician focused on triage safety.",
|
|
56
|
+
}),
|
|
57
|
+
persona({
|
|
58
|
+
name: "Contextual Historian",
|
|
59
|
+
role: "Assesses relevant clinical context",
|
|
60
|
+
systemPrompt: "You evaluate relevant context and confounders.",
|
|
61
|
+
}),
|
|
62
|
+
persona({
|
|
63
|
+
name: "Resource Allocation Analyst",
|
|
64
|
+
role: "Balances triage severity and capacity",
|
|
65
|
+
systemPrompt: "You assess triage decisions against capacity constraints.",
|
|
66
|
+
}),
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
static financialCompliance() {
|
|
70
|
+
return [
|
|
71
|
+
persona({ name: "AML Investigator", role: "Flags suspicious behavior patterns", systemPrompt: "You are an AML investigator." }),
|
|
72
|
+
persona({ name: "Risk Quant", role: "Assesses probabilistic financial risk", systemPrompt: "You are a quantitative risk analyst." }),
|
|
73
|
+
persona({
|
|
74
|
+
name: "Business Controls Reviewer",
|
|
75
|
+
role: "Assesses control proportionality",
|
|
76
|
+
systemPrompt: "You assess control design and business practicality.",
|
|
77
|
+
}),
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
static custom(personas) {
|
|
81
|
+
return personas.map((entry) => persona(entry));
|
|
82
|
+
}
|
|
83
|
+
}
|
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function stripMarkdown(content) {
|
|
2
|
+
const trimmed = content.trim();
|
|
3
|
+
if (trimmed.startsWith("```")) {
|
|
4
|
+
return trimmed
|
|
5
|
+
.split("\n")
|
|
6
|
+
.filter((line) => !line.trim().startsWith("```"))
|
|
7
|
+
.join("\n")
|
|
8
|
+
.trim();
|
|
9
|
+
}
|
|
10
|
+
return trimmed;
|
|
11
|
+
}
|
|
12
|
+
export function safeJsonObject(content) {
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(content);
|
|
15
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return parsed;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@llm-jury/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript package for confidence-driven escalation with expert jury debate",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Mohammed Khalid (https://github.com/mokhld)",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/mokhld/llm-jury.git",
|
|
10
|
+
"directory": "packages/typescript"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/mokhld/llm-jury",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/mokhld/llm-jury/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["llm", "classification", "confidence", "debate", "jury", "escalation", "middleware"],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"llm-jury": "./dist/cli/main.js"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.json",
|
|
31
|
+
"prepack": "npm run build",
|
|
32
|
+
"test": "node --test --experimental-strip-types tests/**/*.test.ts",
|
|
33
|
+
"check": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.13.10",
|
|
41
|
+
"typescript": "^5.8.2"
|
|
42
|
+
}
|
|
43
|
+
}
|