extract-cite 1.0.0 → 1.0.2

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/src/llm/types.ts CHANGED
@@ -111,12 +111,99 @@ export const CITATION_FIELDS: CitationField[] = [
111
111
 
112
112
  /** A field (or one author's qualifications) a human should check. */
113
113
  export interface ReviewItem {
114
- /** A citation field, or `qualifications:<author name>`. */
114
+ /** A citation field, `qualifications:<author name>`, or `content` when the content check found no full article. */
115
115
  field: string;
116
116
  confidence: number;
117
117
  reason: string;
118
118
  }
119
119
 
120
+ /** What the content check concluded about the extracted text. */
121
+ export type ContentVerdict =
122
+ /** The article body is all there. */
123
+ | "full"
124
+ /** A subscribe or sign-in wall replaces or cuts the body. */
125
+ | "paywalled"
126
+ /** The body stops early without a wall: a teaser, an abstract, "Read more". */
127
+ | "truncated"
128
+ /** A bot check, consent wall, access-denied or error page instead of the article. */
129
+ | "blocked"
130
+ /** A home page, index or listing, with no single article. */
131
+ | "not-article"
132
+ /** The model gave no usable verdict. */
133
+ | "unknown";
134
+
135
+ export const CONTENT_VERDICTS: ContentVerdict[] = [
136
+ "full",
137
+ "paywalled",
138
+ "truncated",
139
+ "blocked",
140
+ "not-article",
141
+ "unknown",
142
+ ];
143
+
144
+ /** The kinds of clutter a readability tip can be about. */
145
+ export type PageRegion =
146
+ | "header"
147
+ | "nav"
148
+ | "sidebar"
149
+ | "footer"
150
+ | "ads"
151
+ | "related"
152
+ | "newsletter"
153
+ | "share"
154
+ | "comments"
155
+ | "cookie-banner"
156
+ | "other";
157
+
158
+ export const PAGE_REGIONS: PageRegion[] = [
159
+ "header",
160
+ "nav",
161
+ "sidebar",
162
+ "footer",
163
+ "ads",
164
+ "related",
165
+ "newsletter",
166
+ "share",
167
+ "comments",
168
+ "cookie-banner",
169
+ "other",
170
+ ];
171
+
172
+ /** Clutter the extraction kept, and how to cut it. */
173
+ export interface ReadabilityTip {
174
+ region: PageRegion;
175
+ /** CSS selector of the block to cut. Kept only when it matches an element on the page. */
176
+ selector?: string;
177
+ /** A short snippet of the clutter, kept only when it is in the text. */
178
+ example?: string;
179
+ /** How to cut it, in a sentence. */
180
+ tip: string;
181
+ }
182
+
183
+ /** Whether the extracted content is the full article, and how to make it cleaner. */
184
+ export interface ContentCheck {
185
+ verdict: ContentVerdict;
186
+ /** True only for `"full"`. */
187
+ isFullContent: boolean;
188
+ /** 0–1. */
189
+ confidence: number;
190
+ /** Phrases from the text that show the verdict ("Subscribe to continue reading"); only ones that are in the text are kept. */
191
+ signals: string[];
192
+ /** One or two sentences for the reader. */
193
+ note: string;
194
+ /** CSS selector of the element that holds the article body. Kept only when it matches. */
195
+ contentSelector?: string;
196
+ /** Clutter the content still holds (header, nav, sidebar, footer, …), biggest first. */
197
+ tips: ReadabilityTip[];
198
+ /**
199
+ * The checked selectors in the shape of an `extract-webpage`
200
+ * `extract-selectors-per-domain.json` entry, ready to paste.
201
+ */
202
+ selectors: { content: string[]; remove: string[] };
203
+ /** Words of content the model was shown. */
204
+ wordsChecked: number;
205
+ }
206
+
120
207
  export interface FormattedCitation {
121
208
  /** Plain text. */
122
209
  text: string;
@@ -140,6 +227,8 @@ export interface ExtractCiteLLMResult {
140
227
  origin: Partial<Record<CitationField, "regex" | "llm" | "both">>;
141
228
  /** One entry per requested style. */
142
229
  formatted: Partial<Record<CitationStyle, FormattedCitation>>;
230
+ /** Full article or paywall stub, plus tips for cutting clutter. Absent with `checkContent: false`. */
231
+ contentCheck?: ContentCheck;
143
232
  model: string;
144
233
  ms: number;
145
234
  }
@@ -163,6 +252,15 @@ export interface ExtractCiteLLMOptions {
163
252
  reviewThreshold?: number;
164
253
  /** Characters of page text sent to the model. Default 12000. */
165
254
  maxChars?: number;
255
+ /**
256
+ * The content extracted from the page (HTML or text), e.g. extract-webpage's
257
+ * `html`, for the content check. Default: the page's own visible text.
258
+ */
259
+ content?: string;
260
+ /** Check that the content is the full article and suggest what to cut. Default true. */
261
+ checkContent?: boolean;
262
+ /** Words of content the check is shown, from the start. Default 3000. */
263
+ contentWords?: number;
166
264
  /** Abort the model call after this many milliseconds. Default 60000. */
167
265
  timeoutMs?: number;
168
266
  /** ISO date printed as the access date. Default: today. */