@llm-newsletter-kit/core 1.0.4 → 1.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/dist/index.cjs +23 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -16
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -137,10 +137,12 @@ class AnalyzeImages extends LLMQuery {
|
|
|
137
137
|
if (this.imageMessages.length === 0) {
|
|
138
138
|
return null;
|
|
139
139
|
}
|
|
140
|
-
const {
|
|
140
|
+
const { output } = await ai.generateText({
|
|
141
141
|
model: this.model,
|
|
142
142
|
maxRetries: this.options.llm.maxRetries,
|
|
143
|
-
|
|
143
|
+
output: ai.Output.object({
|
|
144
|
+
schema: this.schema,
|
|
145
|
+
}),
|
|
144
146
|
system: this.systemPrompt,
|
|
145
147
|
messages: [
|
|
146
148
|
{
|
|
@@ -149,7 +151,7 @@ class AnalyzeImages extends LLMQuery {
|
|
|
149
151
|
},
|
|
150
152
|
],
|
|
151
153
|
});
|
|
152
|
-
return
|
|
154
|
+
return output.imageContext;
|
|
153
155
|
}
|
|
154
156
|
get systemPrompt() {
|
|
155
157
|
return `# Image Analysis Expert System
|
|
@@ -256,14 +258,16 @@ class ClassifyTags extends LLMQuery {
|
|
|
256
258
|
}
|
|
257
259
|
async execute({ existTags }) {
|
|
258
260
|
this.existTags = existTags;
|
|
259
|
-
const {
|
|
261
|
+
const { output } = await ai.generateText({
|
|
260
262
|
model: this.model,
|
|
261
263
|
maxRetries: this.options.llm.maxRetries,
|
|
262
|
-
|
|
264
|
+
output: ai.Output.object({
|
|
265
|
+
schema: this.schema,
|
|
266
|
+
}),
|
|
263
267
|
system: this.systemPrompt,
|
|
264
268
|
prompt: this.userPrompt,
|
|
265
269
|
});
|
|
266
|
-
return
|
|
270
|
+
return output;
|
|
267
271
|
}
|
|
268
272
|
get systemPrompt() {
|
|
269
273
|
return `You are an AI specializing in analyzing and categorizing articles for professionals in ${this.expertFields.join(', ')}.
|
|
@@ -336,14 +340,16 @@ class DetermineArticleImportance extends LLMQuery {
|
|
|
336
340
|
this.dateService = config.dateService;
|
|
337
341
|
}
|
|
338
342
|
async execute() {
|
|
339
|
-
const {
|
|
343
|
+
const { output } = await ai.generateText({
|
|
340
344
|
model: this.model,
|
|
341
345
|
maxRetries: this.options.llm.maxRetries,
|
|
342
|
-
|
|
346
|
+
output: ai.Output.object({
|
|
347
|
+
schema: this.schema,
|
|
348
|
+
}),
|
|
343
349
|
system: this.systemPrompt,
|
|
344
350
|
prompt: this.userPrompt,
|
|
345
351
|
});
|
|
346
|
-
return
|
|
352
|
+
return output.importanceScore;
|
|
347
353
|
}
|
|
348
354
|
get minPoint() {
|
|
349
355
|
const targetRule = this.minimumImportanceScoreRules.find(({ targetUrl }) => targetUrl === this.targetArticle.targetUrl);
|
|
@@ -912,7 +918,7 @@ let GenerateNewsletter$1 = class GenerateNewsletter extends BaseLLMQuery {
|
|
|
912
918
|
this.newsletterBrandName = config.newsletterBrandName;
|
|
913
919
|
}
|
|
914
920
|
async execute() {
|
|
915
|
-
const {
|
|
921
|
+
const { output } = await ai.generateText({
|
|
916
922
|
model: this.model,
|
|
917
923
|
maxRetries: this.options.llm.maxRetries,
|
|
918
924
|
maxOutputTokens: this.maxOutputTokens,
|
|
@@ -921,20 +927,22 @@ let GenerateNewsletter$1 = class GenerateNewsletter extends BaseLLMQuery {
|
|
|
921
927
|
topK: this.topK,
|
|
922
928
|
presencePenalty: this.presencePenalty,
|
|
923
929
|
frequencyPenalty: this.frequencyPenalty,
|
|
924
|
-
|
|
930
|
+
output: ai.Output.object({
|
|
931
|
+
schema: this.schema,
|
|
932
|
+
}),
|
|
925
933
|
system: this.systemPrompt,
|
|
926
934
|
prompt: this.userPrompt,
|
|
927
935
|
});
|
|
928
|
-
if (!
|
|
936
|
+
if (!output.isWrittenInOutputLanguage) {
|
|
929
937
|
return this.execute();
|
|
930
938
|
}
|
|
931
|
-
if (!
|
|
939
|
+
if (!output.copyrightVerified) {
|
|
932
940
|
return this.execute();
|
|
933
941
|
}
|
|
934
|
-
if (!
|
|
942
|
+
if (!output.factAccuracy) {
|
|
935
943
|
return this.execute();
|
|
936
944
|
}
|
|
937
|
-
return esToolkit.pick(
|
|
945
|
+
return esToolkit.pick(output, ['title', 'content']);
|
|
938
946
|
}
|
|
939
947
|
get systemPrompt() {
|
|
940
948
|
return `You are a newsletter production expert for "${this.newsletterBrandName}" who analyzes and delivers trends in the fields of ${this.expertFields.join(', ')}. Your goal is to provide in-depth analysis that helps industry professionals easily understand complex information and make informed decisions.
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RunnablePassthrough, RunnableSequence } from '@langchain/core/runnables';
|
|
2
2
|
import { pick, omit } from 'es-toolkit';
|
|
3
|
-
import {
|
|
3
|
+
import { generateText, Output } from 'ai';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import juice from 'juice';
|
|
6
6
|
import DOMPurify from 'dompurify';
|
|
@@ -135,10 +135,12 @@ class AnalyzeImages extends LLMQuery {
|
|
|
135
135
|
if (this.imageMessages.length === 0) {
|
|
136
136
|
return null;
|
|
137
137
|
}
|
|
138
|
-
const {
|
|
138
|
+
const { output } = await generateText({
|
|
139
139
|
model: this.model,
|
|
140
140
|
maxRetries: this.options.llm.maxRetries,
|
|
141
|
-
|
|
141
|
+
output: Output.object({
|
|
142
|
+
schema: this.schema,
|
|
143
|
+
}),
|
|
142
144
|
system: this.systemPrompt,
|
|
143
145
|
messages: [
|
|
144
146
|
{
|
|
@@ -147,7 +149,7 @@ class AnalyzeImages extends LLMQuery {
|
|
|
147
149
|
},
|
|
148
150
|
],
|
|
149
151
|
});
|
|
150
|
-
return
|
|
152
|
+
return output.imageContext;
|
|
151
153
|
}
|
|
152
154
|
get systemPrompt() {
|
|
153
155
|
return `# Image Analysis Expert System
|
|
@@ -254,14 +256,16 @@ class ClassifyTags extends LLMQuery {
|
|
|
254
256
|
}
|
|
255
257
|
async execute({ existTags }) {
|
|
256
258
|
this.existTags = existTags;
|
|
257
|
-
const {
|
|
259
|
+
const { output } = await generateText({
|
|
258
260
|
model: this.model,
|
|
259
261
|
maxRetries: this.options.llm.maxRetries,
|
|
260
|
-
|
|
262
|
+
output: Output.object({
|
|
263
|
+
schema: this.schema,
|
|
264
|
+
}),
|
|
261
265
|
system: this.systemPrompt,
|
|
262
266
|
prompt: this.userPrompt,
|
|
263
267
|
});
|
|
264
|
-
return
|
|
268
|
+
return output;
|
|
265
269
|
}
|
|
266
270
|
get systemPrompt() {
|
|
267
271
|
return `You are an AI specializing in analyzing and categorizing articles for professionals in ${this.expertFields.join(', ')}.
|
|
@@ -334,14 +338,16 @@ class DetermineArticleImportance extends LLMQuery {
|
|
|
334
338
|
this.dateService = config.dateService;
|
|
335
339
|
}
|
|
336
340
|
async execute() {
|
|
337
|
-
const {
|
|
341
|
+
const { output } = await generateText({
|
|
338
342
|
model: this.model,
|
|
339
343
|
maxRetries: this.options.llm.maxRetries,
|
|
340
|
-
|
|
344
|
+
output: Output.object({
|
|
345
|
+
schema: this.schema,
|
|
346
|
+
}),
|
|
341
347
|
system: this.systemPrompt,
|
|
342
348
|
prompt: this.userPrompt,
|
|
343
349
|
});
|
|
344
|
-
return
|
|
350
|
+
return output.importanceScore;
|
|
345
351
|
}
|
|
346
352
|
get minPoint() {
|
|
347
353
|
const targetRule = this.minimumImportanceScoreRules.find(({ targetUrl }) => targetUrl === this.targetArticle.targetUrl);
|
|
@@ -910,7 +916,7 @@ let GenerateNewsletter$1 = class GenerateNewsletter extends BaseLLMQuery {
|
|
|
910
916
|
this.newsletterBrandName = config.newsletterBrandName;
|
|
911
917
|
}
|
|
912
918
|
async execute() {
|
|
913
|
-
const {
|
|
919
|
+
const { output } = await generateText({
|
|
914
920
|
model: this.model,
|
|
915
921
|
maxRetries: this.options.llm.maxRetries,
|
|
916
922
|
maxOutputTokens: this.maxOutputTokens,
|
|
@@ -919,20 +925,22 @@ let GenerateNewsletter$1 = class GenerateNewsletter extends BaseLLMQuery {
|
|
|
919
925
|
topK: this.topK,
|
|
920
926
|
presencePenalty: this.presencePenalty,
|
|
921
927
|
frequencyPenalty: this.frequencyPenalty,
|
|
922
|
-
|
|
928
|
+
output: Output.object({
|
|
929
|
+
schema: this.schema,
|
|
930
|
+
}),
|
|
923
931
|
system: this.systemPrompt,
|
|
924
932
|
prompt: this.userPrompt,
|
|
925
933
|
});
|
|
926
|
-
if (!
|
|
934
|
+
if (!output.isWrittenInOutputLanguage) {
|
|
927
935
|
return this.execute();
|
|
928
936
|
}
|
|
929
|
-
if (!
|
|
937
|
+
if (!output.copyrightVerified) {
|
|
930
938
|
return this.execute();
|
|
931
939
|
}
|
|
932
|
-
if (!
|
|
940
|
+
if (!output.factAccuracy) {
|
|
933
941
|
return this.execute();
|
|
934
942
|
}
|
|
935
|
-
return pick(
|
|
943
|
+
return pick(output, ['title', 'content']);
|
|
936
944
|
}
|
|
937
945
|
get systemPrompt() {
|
|
938
946
|
return `You are a newsletter production expert for "${this.newsletterBrandName}" who analyzes and delivers trends in the fields of ${this.expertFields.join(', ')}. Your goal is to provide in-depth analysis that helps industry professionals easily understand complex information and make informed decisions.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@llm-newsletter-kit/core",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.0
|
|
5
|
+
"version": "1.1.0",
|
|
6
6
|
"description": "An extensible framework to automate your entire newsletter workflow. Handles data collection, LLM-based content analysis, and email generation, letting you focus on your unique domain logic.",
|
|
7
7
|
"main": "dist/index.cjs",
|
|
8
8
|
"module": "dist/index.js",
|
|
@@ -46,31 +46,31 @@
|
|
|
46
46
|
"author": "kimhongyeon",
|
|
47
47
|
"license": "Apache-2.0",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@langchain/core": "^1.1.
|
|
50
|
-
"ai": "^
|
|
49
|
+
"@langchain/core": "^1.1.9",
|
|
50
|
+
"ai": "^6.0.12",
|
|
51
51
|
"dompurify": "^3.3.1",
|
|
52
52
|
"es-toolkit": "^1.43.0",
|
|
53
|
-
"jsdom": "^27.
|
|
54
|
-
"juice": "^11.0
|
|
53
|
+
"jsdom": "^27.4.0",
|
|
54
|
+
"juice": "^11.1.0",
|
|
55
55
|
"marked": "^17.0.1",
|
|
56
|
-
"zod": "^4.
|
|
56
|
+
"zod": "^4.3.5"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@eslint/js": "^9.39.2",
|
|
60
|
-
"@trivago/prettier-plugin-sort-imports": "^6.0.
|
|
60
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.1",
|
|
61
61
|
"@types/jsdom": "^27.0.0",
|
|
62
|
-
"@types/node": "^25.0.
|
|
62
|
+
"@types/node": "^25.0.3",
|
|
63
63
|
"@vitest/coverage-v8": "^3.2.4",
|
|
64
64
|
"@vitest/expect": "^3.2.4",
|
|
65
65
|
"eslint": "^9.39.2",
|
|
66
66
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
67
67
|
"prettier": "^3.7.4",
|
|
68
68
|
"rimraf": "^6.1.2",
|
|
69
|
-
"rollup": "^4.
|
|
69
|
+
"rollup": "^4.55.1",
|
|
70
70
|
"rollup-plugin-dts": "^6.3.0",
|
|
71
71
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
72
72
|
"typescript": "^5.9.3",
|
|
73
|
-
"typescript-eslint": "^8.
|
|
73
|
+
"typescript-eslint": "^8.52.0",
|
|
74
74
|
"vitest": "^3.2.4"
|
|
75
75
|
},
|
|
76
76
|
"repository": {
|