@graphext/cuery 0.5.2 → 0.6.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.
Files changed (42) hide show
  1. package/README.md +5 -0
  2. package/esm/mod.d.ts +1 -0
  3. package/esm/mod.d.ts.map +1 -1
  4. package/esm/mod.js +1 -0
  5. package/esm/src/schemas/index.d.ts +1 -0
  6. package/esm/src/schemas/index.d.ts.map +1 -1
  7. package/esm/src/schemas/summary.schema.d.ts +6 -0
  8. package/esm/src/schemas/summary.schema.d.ts.map +1 -0
  9. package/esm/src/schemas/summary.schema.js +4 -0
  10. package/esm/src/tools/classifier.d.ts +38 -0
  11. package/esm/src/tools/classifier.d.ts.map +1 -1
  12. package/esm/src/tools/classifier.js +73 -0
  13. package/esm/src/tools/entities.d.ts +22 -0
  14. package/esm/src/tools/entities.d.ts.map +1 -1
  15. package/esm/src/tools/entities.js +32 -0
  16. package/esm/src/tools/sentiment.d.ts +20 -2
  17. package/esm/src/tools/sentiment.d.ts.map +1 -1
  18. package/esm/src/tools/sentiment.js +34 -2
  19. package/esm/src/tools/summarize.d.ts +26 -0
  20. package/esm/src/tools/summarize.d.ts.map +1 -0
  21. package/esm/src/tools/summarize.js +57 -0
  22. package/package.json +1 -1
  23. package/script/mod.d.ts +1 -0
  24. package/script/mod.d.ts.map +1 -1
  25. package/script/mod.js +1 -0
  26. package/script/src/schemas/index.d.ts +1 -0
  27. package/script/src/schemas/index.d.ts.map +1 -1
  28. package/script/src/schemas/summary.schema.d.ts +6 -0
  29. package/script/src/schemas/summary.schema.d.ts.map +1 -0
  30. package/script/src/schemas/summary.schema.js +7 -0
  31. package/script/src/tools/classifier.d.ts +38 -0
  32. package/script/src/tools/classifier.d.ts.map +1 -1
  33. package/script/src/tools/classifier.js +76 -1
  34. package/script/src/tools/entities.d.ts +22 -0
  35. package/script/src/tools/entities.d.ts.map +1 -1
  36. package/script/src/tools/entities.js +34 -1
  37. package/script/src/tools/sentiment.d.ts +20 -2
  38. package/script/src/tools/sentiment.d.ts.map +1 -1
  39. package/script/src/tools/sentiment.js +36 -3
  40. package/script/src/tools/summarize.d.ts +26 -0
  41. package/script/src/tools/summarize.d.ts.map +1 -0
  42. package/script/src/tools/summarize.js +62 -0
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Cuery
2
2
 
3
+ [![JSR](https://jsr.io/badges/@graphext/cuery)](https://jsr.io/@graphext/cuery)
4
+ [![npm](https://img.shields.io/npm/v/@graphext/cuery)](https://www.npmjs.com/package/@graphext/cuery)
5
+ [![Release](https://github.com/graphext/cueryjs/actions/workflows/release.yml/badge.svg)](https://github.com/graphext/cueryjs/actions/workflows/release.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+
3
8
  Internal utilities for data processing and analysis.
4
9
 
5
10
  ## Installation
package/esm/mod.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from './src/helpers/utils.js';
16
16
  export * from './src/tools/brands.js';
17
17
  export * from './src/tools/translate.js';
18
18
  export * from './src/tools/sentiment.js';
19
+ export * from './src/tools/summarize.js';
19
20
  export * from './src/tools/sources.js';
20
21
  export * from './src/tools/entities.js';
21
22
  export * from './src/helpers/seedKeywords.js';
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACN,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,SAAS,GACd,MAAM,0BAA0B,CAAC;AAGlC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACN,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,SAAS,GACd,MAAM,0BAA0B,CAAC;AAGlC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC"}
package/esm/mod.js CHANGED
@@ -18,6 +18,7 @@ export * from './src/helpers/utils.js';
18
18
  export * from './src/tools/brands.js';
19
19
  export * from './src/tools/translate.js';
20
20
  export * from './src/tools/sentiment.js';
21
+ export * from './src/tools/summarize.js';
21
22
  export * from './src/tools/sources.js';
22
23
  export * from './src/tools/entities.js';
23
24
  export * from './src/helpers/seedKeywords.js';
@@ -18,4 +18,5 @@ export type * from './pipeline.schema.js';
18
18
  export type * from './models.schema.js';
19
19
  export type * from './seedKeyword.schema.js';
20
20
  export type * from './topics.schema.js';
21
+ export type * from './summary.schema.js';
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { z } from '../../deps/jsr.io/@zod/zod/4.3.6/src/index.js';
2
+ export declare const SummarySchema: z.ZodObject<{
3
+ summary: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export type Summary = z.infer<typeof SummarySchema>;
6
+ //# sourceMappingURL=summary.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.schema.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/summary.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,+CAA+C,CAAC;AAElE,eAAO,MAAM,aAAa;;iBAExB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { z } from '../../deps/jsr.io/@zod/zod/4.3.6/src/index.js';
2
+ export const SummarySchema = z.object({
3
+ summary: z.string().describe('The summarized text, condensed to approximately the target word count while preserving key information.')
4
+ });
@@ -25,6 +25,44 @@ export declare class Classifier extends Tool<Record<string, unknown> | null, {
25
25
  label: string;
26
26
  }): string;
27
27
  }
28
+ /**
29
+ * Predefined communicative intent labels based on the PIE+ framework.
30
+ * These represent the core purposes of communication, writing, and rhetoric.
31
+ */
32
+ export declare const SPEECH_INTENT_LABELS: Record<string, string>;
33
+ /**
34
+ * Configuration for the SpeechIntentClassifier tool.
35
+ */
36
+ export interface SpeechIntentClassifierConfig {
37
+ /** Additional instructions for the classifier */
38
+ instructions?: string;
39
+ }
40
+ /**
41
+ * A tool that classifies text into communicative/speech intents (inform, persuade, entertain, educate, express emotions).
42
+ * Based on the PIE+ framework for understanding author's purpose.
43
+ */
44
+ export declare class SpeechIntentClassifier extends Classifier {
45
+ constructor(config: SpeechIntentClassifierConfig | undefined, modelConfig: ModelConfig);
46
+ }
47
+ /**
48
+ * Predefined emotion labels based on Plutchik's wheel of emotions.
49
+ * These represent the 8 primary emotions organized as 4 opposing pairs.
50
+ */
51
+ export declare const PLUTCHIK_EMOTION_LABELS: Record<string, string>;
52
+ /**
53
+ * Configuration for the PlutchikEmotionClassifier tool.
54
+ */
55
+ export interface PlutchikEmotionClassifierConfig {
56
+ /** Additional instructions for the classifier */
57
+ instructions?: string;
58
+ }
59
+ /**
60
+ * A tool that classifies text into dominant emotions based on Plutchik's wheel of emotions.
61
+ * The 8 primary emotions are organized as 4 opposing pairs: joy/sadness, trust/disgust, fear/anger, surprise/anticipation.
62
+ */
63
+ export declare class PlutchikEmotionClassifier extends Classifier {
64
+ constructor(config: PlutchikEmotionClassifierConfig | undefined, modelConfig: ModelConfig);
65
+ }
28
66
  /**
29
67
  * Configuration for the Labeler tool.
30
68
  */
@@ -1 +1 @@
1
- {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../../src/src/tools/classifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,+CAA+C,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAmGpD,UAAU,gBAAgB;IACzB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,CAAC;IAC9F,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuC;IACnE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAE5B,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW;cAS3C,MAAM;;;;;IAIzB,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;cAIpC,aAAa,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;CAG1D;AAMD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,8CAA8C;IAC9C,YAAY,CAAC,EAAE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107
+ // =============================================================================
108
+ // SpeechIntentClassifier (communicative intent classification)
109
+ // =============================================================================
110
+ /**
111
+ * Predefined communicative intent labels based on the PIE+ framework.
112
+ * These represent the core purposes of communication, writing, and rhetoric.
113
+ */
114
+ export const SPEECH_INTENT_LABELS = {
115
+ inform: 'Provides facts, data, and knowledge about a topic. Uses clear, objective language, numbers, dates, and evidence. Examples: news articles, encyclopedia entries, reports.',
116
+ persuade: 'Aims to influence the audience\'s point of view, convince them of an idea, or move them to action. Uses emotional appeals (pathos), logical reasoning (logos), and expert credibility (ethos). Examples: speeches, advertisements, editorials.',
117
+ entertain: 'Aims to amuse, provide enjoyment, or create a pleasant experience. Uses humor, suspense, vivid imagery, and engaging characters. Examples: novels, poems, stories, comics.',
118
+ educate: 'Aims to teach the audience, instruct them on how to do something, or increase their understanding. Uses step-by-step instructions, clear explanations, and breaks down complex topics. Examples: textbooks, tutorials, how-to guides.',
119
+ express_emotions: 'Shares personal feelings, evokes a specific mood, or connects emotionally with the reader. Uses vivid, emotive, or sensory language. Examples: diary entries, poetry, journals, personal essays.'
120
+ };
121
+ /**
122
+ * Predefined instructions for speech intent classification.
123
+ */
124
+ const SPEECH_INTENT_CLASSIFIER_INSTRUCTIONS = dedent(`
125
+ Focus on the author's PURPOSE, not the topic. A news article about entertainment is "inform", not "entertain".
126
+ Ask yourself: What is the author trying to achieve with this text?
127
+ If the text blends multiple purposes, identify the DOMINANT intent based on the overall structure and goal.
128
+ `);
129
+ /**
130
+ * A tool that classifies text into communicative/speech intents (inform, persuade, entertain, educate, express emotions).
131
+ * Based on the PIE+ framework for understanding author's purpose.
132
+ */
133
+ export class SpeechIntentClassifier extends Classifier {
134
+ constructor(config = {}, modelConfig) {
135
+ const { instructions = '' } = config;
136
+ const combinedInstructions = instructions
137
+ ? `${SPEECH_INTENT_CLASSIFIER_INSTRUCTIONS}\n\n${instructions}`
138
+ : SPEECH_INTENT_CLASSIFIER_INSTRUCTIONS;
139
+ super({ labels: SPEECH_INTENT_LABELS, instructions: combinedInstructions }, modelConfig);
140
+ }
141
+ }
142
+ // =============================================================================
143
+ // PlutchikEmotionClassifier (emotion classification)
144
+ // =============================================================================
145
+ /**
146
+ * Predefined emotion labels based on Plutchik's wheel of emotions.
147
+ * These represent the 8 primary emotions organized as 4 opposing pairs.
148
+ */
149
+ export const PLUTCHIK_EMOTION_LABELS = {
150
+ joy: 'A positive, high-energy state of pleasure, happiness, or contentment. Expressed through uplifting language, celebration, gratitude, or satisfaction.',
151
+ sadness: 'A low-energy state associated with loss, grief, disappointment, or melancholy. Expressed through somber tone, themes of loss, or expressions of sorrow.',
152
+ trust: 'A positive acceptance or affinity for others. Expressed through confidence, reliability, loyalty, or openness to connection.',
153
+ disgust: 'A feeling of revulsion, rejection, or strong disapproval. Expressed through aversion, contempt, or moral judgment.',
154
+ fear: 'An emotional response to danger, threat, or uncertainty. Expressed through anxiety, worry, caution, or alarm.',
155
+ anger: 'A high-arousal response to frustration, injustice, or provocation. Expressed through criticism, outrage, hostility, or aggression.',
156
+ surprise: 'A reaction to unexpected events or information. Expressed through astonishment, disbelief, or sudden realization.',
157
+ anticipation: 'Looking forward to, or preparing for, future events. Expressed through expectation, excitement, hope, or vigilance.'
158
+ };
159
+ /**
160
+ * Predefined instructions for emotion classification.
161
+ */
162
+ const PLUTCHIK_EMOTION_CLASSIFIER_INSTRUCTIONS = dedent(`
163
+ Identify the DOMINANT emotion conveyed by the text, considering both explicit emotional language and implicit tone.
164
+ Focus on what the author/speaker is feeling or trying to evoke in the reader, not the topic being discussed.
165
+ If multiple emotions are present, choose the one that is most central to the text's emotional impact.
166
+ `);
167
+ /**
168
+ * A tool that classifies text into dominant emotions based on Plutchik's wheel of emotions.
169
+ * The 8 primary emotions are organized as 4 opposing pairs: joy/sadness, trust/disgust, fear/anger, surprise/anticipation.
170
+ */
171
+ export class PlutchikEmotionClassifier extends Classifier {
172
+ constructor(config = {}, modelConfig) {
173
+ const { instructions = '' } = config;
174
+ const combinedInstructions = instructions
175
+ ? `${PLUTCHIK_EMOTION_CLASSIFIER_INSTRUCTIONS}\n\n${instructions}`
176
+ : PLUTCHIK_EMOTION_CLASSIFIER_INSTRUCTIONS;
177
+ super({ labels: PLUTCHIK_EMOTION_LABELS, instructions: combinedInstructions }, modelConfig);
178
+ }
179
+ }
107
180
  /**
108
181
  * A tool that assigns one or more labels to records from provided options.
109
182
  */
@@ -25,6 +25,28 @@ export declare class EntityExtractor extends Tool<string | null, Entities, Array
25
25
  protected isEmpty(text: string | null): boolean;
26
26
  protected extractResult(parsed: Entities): Array<Entity>;
27
27
  }
28
+ /**
29
+ * Predefined common entity types for general-purpose extraction.
30
+ */
31
+ export declare const COMMON_ENTITY_DEFINITIONS: Record<string, string>;
32
+ /**
33
+ * Configuration for the CommonEntityExtractor tool.
34
+ */
35
+ export interface CommonEntityExtractorConfig {
36
+ /** Additional entity definitions to merge with common ones */
37
+ additionalDefinitions?: Record<string, string>;
38
+ /** Entity types to exclude from common definitions */
39
+ excludeTypes?: Array<string>;
40
+ /** Additional instructions */
41
+ instructions?: string;
42
+ }
43
+ /**
44
+ * A tool that extracts common entity types (person, organization, location, etc.) from text.
45
+ * Extends EntityExtractor with predefined entity definitions.
46
+ */
47
+ export declare class CommonEntityExtractor extends EntityExtractor {
48
+ constructor(config: CommonEntityExtractorConfig | undefined, modelConfig: ModelConfig);
49
+ }
28
50
  export type { Entity, Entities } from '../schemas/entity.schema.js';
29
51
  export { EntitySchema, EntitiesSchema } from '../schemas/entity.schema.js';
30
52
  //# sourceMappingURL=entities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/src/tools/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAkB,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAkCzF;;GAEG;AACH,MAAM,WAAW,qBAAqB;I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MAAM,CAAC,CAAC;IAChF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAE5B,MAAM,EAAE,qBAAqB,YAAK,EAAE,WAAW,EAAE,WAAW;cAgBrD,MAAM;;;;;;IAIzB,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;cAIjB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;cAIrC,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC;CAGjE;AAMD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAS5D,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,sDAAsD;IACtD,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;gBAC7C,MAAM,EAAE,2BAA2B,YAAK,EAAE,WAAW,EAAE,WAAW;CAe9E;AAGD,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC"}
@@ -57,4 +57,36 @@ export class EntityExtractor extends Tool {
57
57
  return parsed.entities;
58
58
  }
59
59
  }
60
+ // =============================================================================
61
+ // CommonEntityExtractor
62
+ // =============================================================================
63
+ /**
64
+ * Predefined common entity types for general-purpose extraction.
65
+ */
66
+ export const COMMON_ENTITY_DEFINITIONS = {
67
+ person: 'Names of people, individuals, celebrities, public figures',
68
+ organization: 'Companies, institutions, agencies, teams, corporations',
69
+ location: 'Places, cities, countries, regions, addresses, landmarks',
70
+ product: 'Products, services, software, apps, models',
71
+ brand: 'Brand names, trademarks',
72
+ date: 'Dates, time periods, years, seasons',
73
+ money: 'Monetary values, prices, currencies, financial amounts',
74
+ event: 'Events, conferences, meetings, holidays, incidents'
75
+ };
76
+ /**
77
+ * A tool that extracts common entity types (person, organization, location, etc.) from text.
78
+ * Extends EntityExtractor with predefined entity definitions.
79
+ */
80
+ export class CommonEntityExtractor extends EntityExtractor {
81
+ constructor(config = {}, modelConfig) {
82
+ const { additionalDefinitions = {}, excludeTypes = [], instructions = '' } = config;
83
+ // Filter out excluded types and merge with additional definitions
84
+ const filteredDefinitions = Object.fromEntries(Object.entries(COMMON_ENTITY_DEFINITIONS).filter(([type]) => !excludeTypes.includes(type)));
85
+ const mergedDefinitions = {
86
+ ...filteredDefinitions,
87
+ ...additionalDefinitions
88
+ };
89
+ super({ entityDefinitions: mergedDefinitions, instructions }, modelConfig);
90
+ }
91
+ }
60
92
  export { EntitySchema, EntitiesSchema } from '../schemas/entity.schema.js';
@@ -1,7 +1,8 @@
1
- import { Tool, type ModelConfig } from '../tool.js';
2
1
  import type { Message } from '../llm.js';
3
2
  import type { BrandContext } from '../schemas/brand.schema.js';
4
3
  import { type ABSentiment, type ABSentiments } from '../schemas/sentiment.schema.js';
4
+ import { Tool, type ModelConfig } from '../tool.js';
5
+ import { Classifier } from './classifier.js';
5
6
  export interface SentimentExtractorConfig {
6
7
  /** Additional instructions for sentiment extraction */
7
8
  instructions?: string;
@@ -28,6 +29,23 @@ export declare class SentimentExtractor extends Tool<string | null, ABSentiments
28
29
  protected isEmpty(text: string | null): boolean;
29
30
  protected extractResult(parsed: ABSentiments): Array<ABSentiment>;
30
31
  }
31
- export type { ABSentiment, ABSentiments } from '../schemas/sentiment.schema.js';
32
+ /**
33
+ * Sentiment polarity labels for classification.
34
+ */
35
+ export declare const SENTIMENT_POLARITY_LABELS: Record<string, string>;
36
+ /**
37
+ * Configuration for the SentimentPolarityClassifier tool.
38
+ */
39
+ export interface SentimentPolarityClassifierConfig {
40
+ /** Additional instructions for the classifier */
41
+ instructions?: string;
42
+ }
43
+ /**
44
+ * A tool that classifies the overall sentiment polarity of text into positive, neutral, or negative.
45
+ */
46
+ export declare class SentimentPolarityClassifier extends Classifier {
47
+ constructor(config: SentimentPolarityClassifierConfig | undefined, modelConfig: ModelConfig);
48
+ }
32
49
  export { ABSentimentSchema, ABSentimentsSchema } from '../schemas/sentiment.schema.js';
50
+ export type { ABSentiment, ABSentiments } from '../schemas/sentiment.schema.js';
33
51
  //# sourceMappingURL=sentiment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sentiment.d.ts","sourceRoot":"","sources":["../../../src/src/tools/sentiment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAwCzG,MAAM,WAAW,wBAAwB;IACxC,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC5F,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAE1B,MAAM,EAAE,wBAAwB,YAAK,EAAE,WAAW,EAAE,WAAW;cAgBxD,MAAM;;;;;;;;;;IAIzB,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE;cAQ7B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;cAIr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yB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAI5D,CAAC;AAWF;;GAEG;AACH,MAAM,WAAW,iCAAiC;IACjD,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,UAAU;gBAC9C,MAAM,EAAE,iCAAiC,YAAK,EAAE,WAAW,EAAE,WAAW;CAOpF;AAED,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACvF,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,6 +1,7 @@
1
- import { Tool } from '../tool.js';
2
- import { ABSentimentsSchema } from '../schemas/sentiment.schema.js';
3
1
  import { dedent } from '../helpers/utils.js';
2
+ import { ABSentimentsSchema } from '../schemas/sentiment.schema.js';
3
+ import { Tool } from '../tool.js';
4
+ import { Classifier } from './classifier.js';
4
5
  const ABS_PROMPT_SYSTEM = dedent(`
5
6
  You're an expert in Aspect-Based Sentiment Analysis. Your task involves identifying specific
6
7
  entities mentioned in a text (e.g. a person, product, service, or experience) and determining the
@@ -70,4 +71,35 @@ export class SentimentExtractor extends Tool {
70
71
  return parsed.aspects;
71
72
  }
72
73
  }
74
+ // =============================================================================
75
+ // SentimentPolarityClassifier (overall sentiment polarity)
76
+ // =============================================================================
77
+ /**
78
+ * Sentiment polarity labels for classification.
79
+ */
80
+ export const SENTIMENT_POLARITY_LABELS = {
81
+ positive: 'Expresses favorable opinions, approval, satisfaction, or optimism.',
82
+ neutral: 'No clear sentiment expressed; factual, balanced, or ambiguous.',
83
+ negative: 'Expresses unfavorable opinions, criticism, dissatisfaction, or pessimism.'
84
+ };
85
+ /**
86
+ * Predefined instructions for sentiment polarity classification.
87
+ */
88
+ const SENTIMENT_POLARITY_INSTRUCTIONS = dedent(`
89
+ Analyze the overall sentiment polarity of the text.
90
+ Focus on the dominant emotional tone, not individual aspects or entities.
91
+ Consider both explicit sentiment expressions and implicit tone.
92
+ `);
93
+ /**
94
+ * A tool that classifies the overall sentiment polarity of text into positive, neutral, or negative.
95
+ */
96
+ export class SentimentPolarityClassifier extends Classifier {
97
+ constructor(config = {}, modelConfig) {
98
+ const { instructions = '' } = config;
99
+ const combinedInstructions = instructions
100
+ ? `${SENTIMENT_POLARITY_INSTRUCTIONS}\n\n${instructions}`
101
+ : SENTIMENT_POLARITY_INSTRUCTIONS;
102
+ super({ labels: SENTIMENT_POLARITY_LABELS, instructions: combinedInstructions }, modelConfig);
103
+ }
104
+ }
73
105
  export { ABSentimentSchema, ABSentimentsSchema } from '../schemas/sentiment.schema.js';
@@ -0,0 +1,26 @@
1
+ import { Tool, type ModelConfig } from '../tool.js';
2
+ import type { Message } from '../llm.js';
3
+ import { type Summary } from '../schemas/summary.schema.js';
4
+ export interface SummarizerConfig {
5
+ /** Target word count for the summary (default: 100) */
6
+ targetWordCount?: number;
7
+ /** Additional instructions for summarization */
8
+ instructions?: string;
9
+ }
10
+ /**
11
+ * A tool that summarizes long texts into shorter ones.
12
+ */
13
+ export declare class Summarizer extends Tool<string | null, Summary, string> {
14
+ private readonly systemPrompt;
15
+ private readonly targetWordCount;
16
+ constructor(config: SummarizerConfig | undefined, modelConfig: ModelConfig);
17
+ protected schema(): import("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js").ZodObject<{
18
+ summary: import("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js").ZodString;
19
+ }, import("../../deps/jsr.io/@zod/zod/4.3.6/src/v4/core/schemas.js").$strip>;
20
+ protected prompt(text: string | null): Message[];
21
+ protected isEmpty(text: string | null): boolean;
22
+ protected extractResult(parsed: Summary): string;
23
+ }
24
+ export type { Summary } from '../schemas/summary.schema.js';
25
+ export { SummarySchema } from '../schemas/summary.schema.js';
26
+ //# sourceMappingURL=summarize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../../src/src/tools/summarize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAyB3E,MAAM,WAAW,gBAAgB;IAChC,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;IACnE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAE7B,MAAM,EAAE,gBAAgB,YAAK,EAAE,WAAW,EAAE,WAAW;cAUhD,MAAM;;;IAIzB,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE;cAU7B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;cAIrC,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;CAGzD;AAED,YAAY,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { Tool } from '../tool.js';
2
+ import { SummarySchema } from '../schemas/summary.schema.js';
3
+ import { dedent } from '../helpers/utils.js';
4
+ const SUMMARIZE_PROMPT_SYSTEM = dedent(`
5
+ You are an expert at summarizing text. Your task is to condense the given text while preserving
6
+ the most important information, key points, and main ideas.
7
+
8
+ Guidelines:
9
+ 1. Maintain the original tone and style where possible
10
+ 2. Preserve key facts, figures, and important details
11
+ 3. Remove redundant or less important information
12
+ 4. Keep the summary coherent and well-structured
13
+ 5. Target approximately {wordCount} words (some variance is acceptable)
14
+
15
+ {instructions}
16
+ `);
17
+ const SUMMARIZE_PROMPT_USER = dedent(`
18
+ Summarize the following text to approximately {wordCount} words.
19
+
20
+ # Text
21
+
22
+ {text}
23
+ `);
24
+ /**
25
+ * A tool that summarizes long texts into shorter ones.
26
+ */
27
+ export class Summarizer extends Tool {
28
+ systemPrompt;
29
+ targetWordCount;
30
+ constructor(config = {}, modelConfig) {
31
+ super(modelConfig);
32
+ const { targetWordCount = 100, instructions = '' } = config;
33
+ this.targetWordCount = targetWordCount;
34
+ this.systemPrompt = SUMMARIZE_PROMPT_SYSTEM
35
+ .replace('{wordCount}', String(targetWordCount))
36
+ .replace('{instructions}', instructions);
37
+ }
38
+ schema() {
39
+ return SummarySchema;
40
+ }
41
+ prompt(text) {
42
+ const userPrompt = SUMMARIZE_PROMPT_USER
43
+ .replace('{wordCount}', String(this.targetWordCount))
44
+ .replace('{text}', text ?? '');
45
+ return [
46
+ { role: 'system', content: this.systemPrompt },
47
+ { role: 'user', content: userPrompt }
48
+ ];
49
+ }
50
+ isEmpty(text) {
51
+ return text == null || text.trim() === '';
52
+ }
53
+ extractResult(parsed) {
54
+ return parsed.summary;
55
+ }
56
+ }
57
+ export { SummarySchema } from '../schemas/summary.schema.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphext/cuery",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "Cuery tools for AI-powered keyword research and brand analysis",
5
5
  "repository": {
6
6
  "type": "git",
package/script/mod.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from './src/helpers/utils.js';
16
16
  export * from './src/tools/brands.js';
17
17
  export * from './src/tools/translate.js';
18
18
  export * from './src/tools/sentiment.js';
19
+ export * from './src/tools/summarize.js';
19
20
  export * from './src/tools/sources.js';
20
21
  export * from './src/tools/entities.js';
21
22
  export * from './src/helpers/seedKeywords.js';
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["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;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC"}
package/script/mod.js CHANGED
@@ -41,6 +41,7 @@ __exportStar(require("./src/helpers/utils.js"), exports);
41
41
  __exportStar(require("./src/tools/brands.js"), exports);
42
42
  __exportStar(require("./src/tools/translate.js"), exports);
43
43
  __exportStar(require("./src/tools/sentiment.js"), exports);
44
+ __exportStar(require("./src/tools/summarize.js"), exports);
44
45
  __exportStar(require("./src/tools/sources.js"), exports);
45
46
  __exportStar(require("./src/tools/entities.js"), exports);
46
47
  __exportStar(require("./src/helpers/seedKeywords.js"), exports);
@@ -18,4 +18,5 @@ export type * from './pipeline.schema.js';
18
18
  export type * from './models.schema.js';
19
19
  export type * from './seedKeyword.schema.js';
20
20
  export type * from './topics.schema.js';
21
+ export type * from './summary.schema.js';
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { z } from '../../deps/jsr.io/@zod/zod/4.3.6/src/index.js';
2
+ export declare const SummarySchema: z.ZodObject<{
3
+ summary: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export type Summary = z.infer<typeof SummarySchema>;
6
+ //# sourceMappingURL=summary.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.schema.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/summary.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,+CAA+C,CAAC;AAElE,eAAO,MAAM,aAAa;;iBAExB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SummarySchema = void 0;
4
+ const index_js_1 = require("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js");
5
+ exports.SummarySchema = index_js_1.z.object({
6
+ summary: index_js_1.z.string().describe('The summarized text, condensed to approximately the target word count while preserving key information.')
7
+ });
@@ -25,6 +25,44 @@ export declare class Classifier extends Tool<Record<string, unknown> | null, {
25
25
  label: string;
26
26
  }): string;
27
27
  }
28
+ /**
29
+ * Predefined communicative intent labels based on the PIE+ framework.
30
+ * These represent the core purposes of communication, writing, and rhetoric.
31
+ */
32
+ export declare const SPEECH_INTENT_LABELS: Record<string, string>;
33
+ /**
34
+ * Configuration for the SpeechIntentClassifier tool.
35
+ */
36
+ export interface SpeechIntentClassifierConfig {
37
+ /** Additional instructions for the classifier */
38
+ instructions?: string;
39
+ }
40
+ /**
41
+ * A tool that classifies text into communicative/speech intents (inform, persuade, entertain, educate, express emotions).
42
+ * Based on the PIE+ framework for understanding author's purpose.
43
+ */
44
+ export declare class SpeechIntentClassifier extends Classifier {
45
+ constructor(config: SpeechIntentClassifierConfig | undefined, modelConfig: ModelConfig);
46
+ }
47
+ /**
48
+ * Predefined emotion labels based on Plutchik's wheel of emotions.
49
+ * These represent the 8 primary emotions organized as 4 opposing pairs.
50
+ */
51
+ export declare const PLUTCHIK_EMOTION_LABELS: Record<string, string>;
52
+ /**
53
+ * Configuration for the PlutchikEmotionClassifier tool.
54
+ */
55
+ export interface PlutchikEmotionClassifierConfig {
56
+ /** Additional instructions for the classifier */
57
+ instructions?: string;
58
+ }
59
+ /**
60
+ * A tool that classifies text into dominant emotions based on Plutchik's wheel of emotions.
61
+ * The 8 primary emotions are organized as 4 opposing pairs: joy/sadness, trust/disgust, fear/anger, surprise/anticipation.
62
+ */
63
+ export declare class PlutchikEmotionClassifier extends Classifier {
64
+ constructor(config: PlutchikEmotionClassifierConfig | undefined, modelConfig: ModelConfig);
65
+ }
28
66
  /**
29
67
  * Configuration for the Labeler tool.
30
68
  */
@@ -1 +1 @@
1
- {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../../src/src/tools/classifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,+CAA+C,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAmGpD,UAAU,gBAAgB;IACzB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,I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;gBAE5B,MAAM,EAAE,oBAAoB,YAAK,EAAE,WAAW,EAAE,WAAW;cAgBpD,MAAM;;;;;;IAIzB,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;cAQrC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO;cAIzD,aAAa,CAC/B,MAAM,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,GAC9D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGzB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LabelExtractor = exports.Labeler = exports.Classifier = void 0;
3
+ exports.LabelExtractor = exports.Labeler = exports.PlutchikEmotionClassifier = exports.PLUTCHIK_EMOTION_LABELS = exports.SpeechIntentClassifier = exports.SPEECH_INTENT_LABELS = exports.Classifier = void 0;
4
4
  const index_js_1 = require("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js");
5
5
  const tool_js_1 = require("../tool.js");
6
6
  const utils_js_1 = require("../helpers/utils.js");
@@ -108,6 +108,81 @@ class Classifier extends tool_js_1.Tool {
108
108
  }
109
109
  }
110
110
  exports.Classifier = Classifier;
111
+ // =============================================================================
112
+ // SpeechIntentClassifier (communicative intent classification)
113
+ // =============================================================================
114
+ /**
115
+ * Predefined communicative intent labels based on the PIE+ framework.
116
+ * These represent the core purposes of communication, writing, and rhetoric.
117
+ */
118
+ exports.SPEECH_INTENT_LABELS = {
119
+ inform: 'Provides facts, data, and knowledge about a topic. Uses clear, objective language, numbers, dates, and evidence. Examples: news articles, encyclopedia entries, reports.',
120
+ persuade: 'Aims to influence the audience\'s point of view, convince them of an idea, or move them to action. Uses emotional appeals (pathos), logical reasoning (logos), and expert credibility (ethos). Examples: speeches, advertisements, editorials.',
121
+ entertain: 'Aims to amuse, provide enjoyment, or create a pleasant experience. Uses humor, suspense, vivid imagery, and engaging characters. Examples: novels, poems, stories, comics.',
122
+ educate: 'Aims to teach the audience, instruct them on how to do something, or increase their understanding. Uses step-by-step instructions, clear explanations, and breaks down complex topics. Examples: textbooks, tutorials, how-to guides.',
123
+ express_emotions: 'Shares personal feelings, evokes a specific mood, or connects emotionally with the reader. Uses vivid, emotive, or sensory language. Examples: diary entries, poetry, journals, personal essays.'
124
+ };
125
+ /**
126
+ * Predefined instructions for speech intent classification.
127
+ */
128
+ const SPEECH_INTENT_CLASSIFIER_INSTRUCTIONS = (0, utils_js_1.dedent)(`
129
+ Focus on the author's PURPOSE, not the topic. A news article about entertainment is "inform", not "entertain".
130
+ Ask yourself: What is the author trying to achieve with this text?
131
+ If the text blends multiple purposes, identify the DOMINANT intent based on the overall structure and goal.
132
+ `);
133
+ /**
134
+ * A tool that classifies text into communicative/speech intents (inform, persuade, entertain, educate, express emotions).
135
+ * Based on the PIE+ framework for understanding author's purpose.
136
+ */
137
+ class SpeechIntentClassifier extends Classifier {
138
+ constructor(config = {}, modelConfig) {
139
+ const { instructions = '' } = config;
140
+ const combinedInstructions = instructions
141
+ ? `${SPEECH_INTENT_CLASSIFIER_INSTRUCTIONS}\n\n${instructions}`
142
+ : SPEECH_INTENT_CLASSIFIER_INSTRUCTIONS;
143
+ super({ labels: exports.SPEECH_INTENT_LABELS, instructions: combinedInstructions }, modelConfig);
144
+ }
145
+ }
146
+ exports.SpeechIntentClassifier = SpeechIntentClassifier;
147
+ // =============================================================================
148
+ // PlutchikEmotionClassifier (emotion classification)
149
+ // =============================================================================
150
+ /**
151
+ * Predefined emotion labels based on Plutchik's wheel of emotions.
152
+ * These represent the 8 primary emotions organized as 4 opposing pairs.
153
+ */
154
+ exports.PLUTCHIK_EMOTION_LABELS = {
155
+ joy: 'A positive, high-energy state of pleasure, happiness, or contentment. Expressed through uplifting language, celebration, gratitude, or satisfaction.',
156
+ sadness: 'A low-energy state associated with loss, grief, disappointment, or melancholy. Expressed through somber tone, themes of loss, or expressions of sorrow.',
157
+ trust: 'A positive acceptance or affinity for others. Expressed through confidence, reliability, loyalty, or openness to connection.',
158
+ disgust: 'A feeling of revulsion, rejection, or strong disapproval. Expressed through aversion, contempt, or moral judgment.',
159
+ fear: 'An emotional response to danger, threat, or uncertainty. Expressed through anxiety, worry, caution, or alarm.',
160
+ anger: 'A high-arousal response to frustration, injustice, or provocation. Expressed through criticism, outrage, hostility, or aggression.',
161
+ surprise: 'A reaction to unexpected events or information. Expressed through astonishment, disbelief, or sudden realization.',
162
+ anticipation: 'Looking forward to, or preparing for, future events. Expressed through expectation, excitement, hope, or vigilance.'
163
+ };
164
+ /**
165
+ * Predefined instructions for emotion classification.
166
+ */
167
+ const PLUTCHIK_EMOTION_CLASSIFIER_INSTRUCTIONS = (0, utils_js_1.dedent)(`
168
+ Identify the DOMINANT emotion conveyed by the text, considering both explicit emotional language and implicit tone.
169
+ Focus on what the author/speaker is feeling or trying to evoke in the reader, not the topic being discussed.
170
+ If multiple emotions are present, choose the one that is most central to the text's emotional impact.
171
+ `);
172
+ /**
173
+ * A tool that classifies text into dominant emotions based on Plutchik's wheel of emotions.
174
+ * The 8 primary emotions are organized as 4 opposing pairs: joy/sadness, trust/disgust, fear/anger, surprise/anticipation.
175
+ */
176
+ class PlutchikEmotionClassifier extends Classifier {
177
+ constructor(config = {}, modelConfig) {
178
+ const { instructions = '' } = config;
179
+ const combinedInstructions = instructions
180
+ ? `${PLUTCHIK_EMOTION_CLASSIFIER_INSTRUCTIONS}\n\n${instructions}`
181
+ : PLUTCHIK_EMOTION_CLASSIFIER_INSTRUCTIONS;
182
+ super({ labels: exports.PLUTCHIK_EMOTION_LABELS, instructions: combinedInstructions }, modelConfig);
183
+ }
184
+ }
185
+ exports.PlutchikEmotionClassifier = PlutchikEmotionClassifier;
111
186
  /**
112
187
  * A tool that assigns one or more labels to records from provided options.
113
188
  */
@@ -25,6 +25,28 @@ export declare class EntityExtractor extends Tool<string | null, Entities, Array
25
25
  protected isEmpty(text: string | null): boolean;
26
26
  protected extractResult(parsed: Entities): Array<Entity>;
27
27
  }
28
+ /**
29
+ * Predefined common entity types for general-purpose extraction.
30
+ */
31
+ export declare const COMMON_ENTITY_DEFINITIONS: Record<string, string>;
32
+ /**
33
+ * Configuration for the CommonEntityExtractor tool.
34
+ */
35
+ export interface CommonEntityExtractorConfig {
36
+ /** Additional entity definitions to merge with common ones */
37
+ additionalDefinitions?: Record<string, string>;
38
+ /** Entity types to exclude from common definitions */
39
+ excludeTypes?: Array<string>;
40
+ /** Additional instructions */
41
+ instructions?: string;
42
+ }
43
+ /**
44
+ * A tool that extracts common entity types (person, organization, location, etc.) from text.
45
+ * Extends EntityExtractor with predefined entity definitions.
46
+ */
47
+ export declare class CommonEntityExtractor extends EntityExtractor {
48
+ constructor(config: CommonEntityExtractorConfig | undefined, modelConfig: ModelConfig);
49
+ }
28
50
  export type { Entity, Entities } from '../schemas/entity.schema.js';
29
51
  export { EntitySchema, EntitiesSchema } from '../schemas/entity.schema.js';
30
52
  //# sourceMappingURL=entities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/src/tools/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAkB,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAkCzF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,qEAAqE;IACrE,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,IAAI,CAAC,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cAIjB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;cAIrC,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC;CAGjE;AAMD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAS5D,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,sDAAsD;IACtD,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;gBAC7C,MAAM,EAAE,2BAA2B,YAAK,EAAE,WAAW,EAAE,WAAW;CAe9E;AAGD,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntitiesSchema = exports.EntitySchema = exports.EntityExtractor = void 0;
3
+ exports.EntitiesSchema = exports.EntitySchema = exports.CommonEntityExtractor = exports.COMMON_ENTITY_DEFINITIONS = exports.EntityExtractor = void 0;
4
4
  const tool_js_1 = require("../tool.js");
5
5
  const entity_schema_js_1 = require("../schemas/entity.schema.js");
6
6
  const utils_js_1 = require("../helpers/utils.js");
@@ -61,6 +61,39 @@ class EntityExtractor extends tool_js_1.Tool {
61
61
  }
62
62
  }
63
63
  exports.EntityExtractor = EntityExtractor;
64
+ // =============================================================================
65
+ // CommonEntityExtractor
66
+ // =============================================================================
67
+ /**
68
+ * Predefined common entity types for general-purpose extraction.
69
+ */
70
+ exports.COMMON_ENTITY_DEFINITIONS = {
71
+ person: 'Names of people, individuals, celebrities, public figures',
72
+ organization: 'Companies, institutions, agencies, teams, corporations',
73
+ location: 'Places, cities, countries, regions, addresses, landmarks',
74
+ product: 'Products, services, software, apps, models',
75
+ brand: 'Brand names, trademarks',
76
+ date: 'Dates, time periods, years, seasons',
77
+ money: 'Monetary values, prices, currencies, financial amounts',
78
+ event: 'Events, conferences, meetings, holidays, incidents'
79
+ };
80
+ /**
81
+ * A tool that extracts common entity types (person, organization, location, etc.) from text.
82
+ * Extends EntityExtractor with predefined entity definitions.
83
+ */
84
+ class CommonEntityExtractor extends EntityExtractor {
85
+ constructor(config = {}, modelConfig) {
86
+ const { additionalDefinitions = {}, excludeTypes = [], instructions = '' } = config;
87
+ // Filter out excluded types and merge with additional definitions
88
+ const filteredDefinitions = Object.fromEntries(Object.entries(exports.COMMON_ENTITY_DEFINITIONS).filter(([type]) => !excludeTypes.includes(type)));
89
+ const mergedDefinitions = {
90
+ ...filteredDefinitions,
91
+ ...additionalDefinitions
92
+ };
93
+ super({ entityDefinitions: mergedDefinitions, instructions }, modelConfig);
94
+ }
95
+ }
96
+ exports.CommonEntityExtractor = CommonEntityExtractor;
64
97
  var entity_schema_js_2 = require("../schemas/entity.schema.js");
65
98
  Object.defineProperty(exports, "EntitySchema", { enumerable: true, get: function () { return entity_schema_js_2.EntitySchema; } });
66
99
  Object.defineProperty(exports, "EntitiesSchema", { enumerable: true, get: function () { return entity_schema_js_2.EntitiesSchema; } });
@@ -1,7 +1,8 @@
1
- import { Tool, type ModelConfig } from '../tool.js';
2
1
  import type { Message } from '../llm.js';
3
2
  import type { BrandContext } from '../schemas/brand.schema.js';
4
3
  import { type ABSentiment, type ABSentiments } from '../schemas/sentiment.schema.js';
4
+ import { Tool, type ModelConfig } from '../tool.js';
5
+ import { Classifier } from './classifier.js';
5
6
  export interface SentimentExtractorConfig {
6
7
  /** Additional instructions for sentiment extraction */
7
8
  instructions?: string;
@@ -28,6 +29,23 @@ export declare class SentimentExtractor extends Tool<string | null, ABSentiments
28
29
  protected isEmpty(text: string | null): boolean;
29
30
  protected extractResult(parsed: ABSentiments): Array<ABSentiment>;
30
31
  }
31
- export type { ABSentiment, ABSentiments } from '../schemas/sentiment.schema.js';
32
+ /**
33
+ * Sentiment polarity labels for classification.
34
+ */
35
+ export declare const SENTIMENT_POLARITY_LABELS: Record<string, string>;
36
+ /**
37
+ * Configuration for the SentimentPolarityClassifier tool.
38
+ */
39
+ export interface SentimentPolarityClassifierConfig {
40
+ /** Additional instructions for the classifier */
41
+ instructions?: string;
42
+ }
43
+ /**
44
+ * A tool that classifies the overall sentiment polarity of text into positive, neutral, or negative.
45
+ */
46
+ export declare class SentimentPolarityClassifier extends Classifier {
47
+ constructor(config: SentimentPolarityClassifierConfig | undefined, modelConfig: ModelConfig);
48
+ }
32
49
  export { ABSentimentSchema, ABSentimentsSchema } from '../schemas/sentiment.schema.js';
50
+ export type { ABSentiment, ABSentiments } from '../schemas/sentiment.schema.js';
33
51
  //# sourceMappingURL=sentiment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sentiment.d.ts","sourceRoot":"","sources":["../../../src/src/tools/sentiment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAwCzG,MAAM,WAAW,wBAAwB;IACxC,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,YAAY,EA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B,YAAK,EAAE,WAAW,EAAE,WAAW;cAgBxD,MAAM;;;;;;;;;;IAIzB,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE;cAQ7B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;cAIrC,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC;CAG1E;AAMD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAI5D,CAAC;AAWF;;GAEG;AACH,MAAM,WAAW,iCAAiC;IACjD,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,UAAU;gBAC9C,MAAM,EAAE,iCAAiC,YAAK,EAAE,WAAW,EAAE,WAAW;CAOpF;AAED,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACvF,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ABSentimentsSchema = exports.ABSentimentSchema = exports.SentimentExtractor = void 0;
4
- const tool_js_1 = require("../tool.js");
5
- const sentiment_schema_js_1 = require("../schemas/sentiment.schema.js");
3
+ exports.ABSentimentsSchema = exports.ABSentimentSchema = exports.SentimentPolarityClassifier = exports.SENTIMENT_POLARITY_LABELS = exports.SentimentExtractor = void 0;
6
4
  const utils_js_1 = require("../helpers/utils.js");
5
+ const sentiment_schema_js_1 = require("../schemas/sentiment.schema.js");
6
+ const tool_js_1 = require("../tool.js");
7
+ const classifier_js_1 = require("./classifier.js");
7
8
  const ABS_PROMPT_SYSTEM = (0, utils_js_1.dedent)(`
8
9
  You're an expert in Aspect-Based Sentiment Analysis. Your task involves identifying specific
9
10
  entities mentioned in a text (e.g. a person, product, service, or experience) and determining the
@@ -74,6 +75,38 @@ class SentimentExtractor extends tool_js_1.Tool {
74
75
  }
75
76
  }
76
77
  exports.SentimentExtractor = SentimentExtractor;
78
+ // =============================================================================
79
+ // SentimentPolarityClassifier (overall sentiment polarity)
80
+ // =============================================================================
81
+ /**
82
+ * Sentiment polarity labels for classification.
83
+ */
84
+ exports.SENTIMENT_POLARITY_LABELS = {
85
+ positive: 'Expresses favorable opinions, approval, satisfaction, or optimism.',
86
+ neutral: 'No clear sentiment expressed; factual, balanced, or ambiguous.',
87
+ negative: 'Expresses unfavorable opinions, criticism, dissatisfaction, or pessimism.'
88
+ };
89
+ /**
90
+ * Predefined instructions for sentiment polarity classification.
91
+ */
92
+ const SENTIMENT_POLARITY_INSTRUCTIONS = (0, utils_js_1.dedent)(`
93
+ Analyze the overall sentiment polarity of the text.
94
+ Focus on the dominant emotional tone, not individual aspects or entities.
95
+ Consider both explicit sentiment expressions and implicit tone.
96
+ `);
97
+ /**
98
+ * A tool that classifies the overall sentiment polarity of text into positive, neutral, or negative.
99
+ */
100
+ class SentimentPolarityClassifier extends classifier_js_1.Classifier {
101
+ constructor(config = {}, modelConfig) {
102
+ const { instructions = '' } = config;
103
+ const combinedInstructions = instructions
104
+ ? `${SENTIMENT_POLARITY_INSTRUCTIONS}\n\n${instructions}`
105
+ : SENTIMENT_POLARITY_INSTRUCTIONS;
106
+ super({ labels: exports.SENTIMENT_POLARITY_LABELS, instructions: combinedInstructions }, modelConfig);
107
+ }
108
+ }
109
+ exports.SentimentPolarityClassifier = SentimentPolarityClassifier;
77
110
  var sentiment_schema_js_2 = require("../schemas/sentiment.schema.js");
78
111
  Object.defineProperty(exports, "ABSentimentSchema", { enumerable: true, get: function () { return sentiment_schema_js_2.ABSentimentSchema; } });
79
112
  Object.defineProperty(exports, "ABSentimentsSchema", { enumerable: true, get: function () { return sentiment_schema_js_2.ABSentimentsSchema; } });
@@ -0,0 +1,26 @@
1
+ import { Tool, type ModelConfig } from '../tool.js';
2
+ import type { Message } from '../llm.js';
3
+ import { type Summary } from '../schemas/summary.schema.js';
4
+ export interface SummarizerConfig {
5
+ /** Target word count for the summary (default: 100) */
6
+ targetWordCount?: number;
7
+ /** Additional instructions for summarization */
8
+ instructions?: string;
9
+ }
10
+ /**
11
+ * A tool that summarizes long texts into shorter ones.
12
+ */
13
+ export declare class Summarizer extends Tool<string | null, Summary, string> {
14
+ private readonly systemPrompt;
15
+ private readonly targetWordCount;
16
+ constructor(config: SummarizerConfig | undefined, modelConfig: ModelConfig);
17
+ protected schema(): import("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js").ZodObject<{
18
+ summary: import("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js").ZodString;
19
+ }, import("../../deps/jsr.io/@zod/zod/4.3.6/src/v4/core/schemas.js").$strip>;
20
+ protected prompt(text: string | null): Message[];
21
+ protected isEmpty(text: string | null): boolean;
22
+ protected extractResult(parsed: Summary): string;
23
+ }
24
+ export type { Summary } from '../schemas/summary.schema.js';
25
+ export { SummarySchema } from '../schemas/summary.schema.js';
26
+ //# sourceMappingURL=summarize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../../src/src/tools/summarize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAyB3E,MAAM,WAAW,gBAAgB;IAChC,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;IACnE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAE7B,MAAM,EAAE,gBAAgB,YAAK,EAAE,WAAW,EAAE,WAAW;cAUhD,MAAM;;;IAIzB,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE;cAU7B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;cAIrC,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;CAGzD;AAED,YAAY,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SummarySchema = exports.Summarizer = void 0;
4
+ const tool_js_1 = require("../tool.js");
5
+ const summary_schema_js_1 = require("../schemas/summary.schema.js");
6
+ const utils_js_1 = require("../helpers/utils.js");
7
+ const SUMMARIZE_PROMPT_SYSTEM = (0, utils_js_1.dedent)(`
8
+ You are an expert at summarizing text. Your task is to condense the given text while preserving
9
+ the most important information, key points, and main ideas.
10
+
11
+ Guidelines:
12
+ 1. Maintain the original tone and style where possible
13
+ 2. Preserve key facts, figures, and important details
14
+ 3. Remove redundant or less important information
15
+ 4. Keep the summary coherent and well-structured
16
+ 5. Target approximately {wordCount} words (some variance is acceptable)
17
+
18
+ {instructions}
19
+ `);
20
+ const SUMMARIZE_PROMPT_USER = (0, utils_js_1.dedent)(`
21
+ Summarize the following text to approximately {wordCount} words.
22
+
23
+ # Text
24
+
25
+ {text}
26
+ `);
27
+ /**
28
+ * A tool that summarizes long texts into shorter ones.
29
+ */
30
+ class Summarizer extends tool_js_1.Tool {
31
+ systemPrompt;
32
+ targetWordCount;
33
+ constructor(config = {}, modelConfig) {
34
+ super(modelConfig);
35
+ const { targetWordCount = 100, instructions = '' } = config;
36
+ this.targetWordCount = targetWordCount;
37
+ this.systemPrompt = SUMMARIZE_PROMPT_SYSTEM
38
+ .replace('{wordCount}', String(targetWordCount))
39
+ .replace('{instructions}', instructions);
40
+ }
41
+ schema() {
42
+ return summary_schema_js_1.SummarySchema;
43
+ }
44
+ prompt(text) {
45
+ const userPrompt = SUMMARIZE_PROMPT_USER
46
+ .replace('{wordCount}', String(this.targetWordCount))
47
+ .replace('{text}', text ?? '');
48
+ return [
49
+ { role: 'system', content: this.systemPrompt },
50
+ { role: 'user', content: userPrompt }
51
+ ];
52
+ }
53
+ isEmpty(text) {
54
+ return text == null || text.trim() === '';
55
+ }
56
+ extractResult(parsed) {
57
+ return parsed.summary;
58
+ }
59
+ }
60
+ exports.Summarizer = Summarizer;
61
+ var summary_schema_js_2 = require("../schemas/summary.schema.js");
62
+ Object.defineProperty(exports, "SummarySchema", { enumerable: true, get: function () { return summary_schema_js_2.SummarySchema; } });