@newses/plugin-digest-summary 0.3.2 → 0.4.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/digest.d.ts +12 -6
- package/dist/digest.js +48 -31
- package/dist/index.js +20 -81
- package/dist/messages.d.ts +597 -0
- package/dist/messages.js +595 -0
- package/dist/prices.d.ts +3 -2
- package/dist/prices.js +8 -2
- package/dist/providers/anthropic.d.ts +4 -3
- package/dist/providers/anthropic.js +15 -15
- package/dist/providers/bedrock.d.ts +7 -3
- package/dist/providers/bedrock.js +33 -30
- package/dist/providers/http.d.ts +10 -2
- package/dist/providers/http.js +16 -14
- package/dist/providers/index.d.ts +6 -2
- package/dist/providers/index.js +10 -6
- package/dist/providers/ollama.d.ts +2 -1
- package/dist/providers/ollama.js +18 -9
- package/dist/providers/openai.d.ts +2 -1
- package/dist/providers/openai.js +11 -8
- package/dist/settings.d.ts +1 -1
- package/dist/settings.js +8 -6
- package/package.json +3 -3
package/dist/digest.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type DigestComposeInput, type DigestEntry, type DigestSection, type Plu
|
|
|
2
2
|
import { PART_TOKENS } from './providers/anthropic.js';
|
|
3
3
|
import type { Capacity, Provider } from './providers/index.js';
|
|
4
4
|
import { type FeedArticles, type Overview } from './prompts.js';
|
|
5
|
+
import { type Say } from './messages.js';
|
|
5
6
|
import { type RequestTokens } from './prices.js';
|
|
6
7
|
import { type InstanceSettings, type UserSettings } from './settings.js';
|
|
7
8
|
import { estimateTokens } from './tokens.js';
|
|
@@ -130,10 +131,11 @@ export declare function additionsOf(overview: Overview, userSettings: Pick<UserS
|
|
|
130
131
|
sections: DigestSection[];
|
|
131
132
|
};
|
|
132
133
|
/**
|
|
133
|
-
* What the overview of a digest is expected to cost, making no request, as plain text
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* would take at the speed it last
|
|
134
|
+
* What the overview of a digest is expected to cost, making no request, as plain text in the
|
|
135
|
+
* reader's language (`say`, `language`; English by default): how it would be read, its tokens,
|
|
136
|
+
* and US dollars at list prices, or why it would add nothing. A self-hosted model's has no price,
|
|
137
|
+
* but how many articles its context holds, and how long it would take at the speed it last
|
|
138
|
+
* answered at.
|
|
137
139
|
*/
|
|
138
140
|
export declare function estimate(options: {
|
|
139
141
|
provider: Pick<Provider, 'label' | 'capacity' | 'parallel'>;
|
|
@@ -143,6 +145,8 @@ export declare function estimate(options: {
|
|
|
143
145
|
storage: PluginStore;
|
|
144
146
|
userStorage: PluginStore | null;
|
|
145
147
|
now: () => Date;
|
|
148
|
+
say?: Say;
|
|
149
|
+
language?: string;
|
|
146
150
|
}): Promise<string>;
|
|
147
151
|
/** What a digest's overview ended as, and what it adds to the digest. */
|
|
148
152
|
export interface Composed {
|
|
@@ -168,12 +172,14 @@ export declare function compose(options: {
|
|
|
168
172
|
/** When the overview must be written by, in ms since the epoch. */
|
|
169
173
|
deadline: number;
|
|
170
174
|
now: () => Date;
|
|
175
|
+
/** What the overview says of itself, in the digest's language; English by default. */
|
|
176
|
+
say?: Say;
|
|
171
177
|
}): Promise<Composed>;
|
|
172
|
-
/** What an overview written from only some parts says of the rest. */
|
|
178
|
+
/** What an overview written from only some parts says of the rest, in the digest's language. */
|
|
173
179
|
export declare function missingNote(counts: {
|
|
174
180
|
read: number;
|
|
175
181
|
given: number;
|
|
176
182
|
parts: number;
|
|
177
183
|
timedOut: number;
|
|
178
184
|
failed: number;
|
|
179
|
-
}): string;
|
|
185
|
+
}, say?: Say, language?: string): string;
|
package/dist/digest.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DIGEST_LIMITS, } from '@newses/plugin-api';
|
|
2
2
|
import { PART_TOKENS } from './providers/anthropic.js';
|
|
3
3
|
import { MERGE_SYSTEM, mergePrompt, OVERVIEW_SYSTEM, overviewPrompt, PART_SYSTEM, partFormat, partPrompt, partThemes, preferencesText, readPart, readSections, sectionsFormat, sectionsOf, } from './prompts.js';
|
|
4
|
+
import { counted, english, numbers } from './messages.js';
|
|
4
5
|
import { costOf, dollars, premiumOf, tokensIn } from './prices.js';
|
|
5
6
|
import { DEFAULT_SECTIONS, INSTRUCTIONS_LENGTH, } from './settings.js';
|
|
6
7
|
import { estimateTokens } from './tokens.js';
|
|
@@ -319,40 +320,53 @@ function secondsAt(speed, planned, parallel) {
|
|
|
319
320
|
return (parts.reduce((sum, s) => sum + s, 0) / Math.min(parallel, parts.length) + (seconds.at(-1) ?? 0));
|
|
320
321
|
}
|
|
321
322
|
/**
|
|
322
|
-
* What the overview of a digest is expected to cost, making no request, as plain text
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* would take at the speed it last
|
|
323
|
+
* What the overview of a digest is expected to cost, making no request, as plain text in the
|
|
324
|
+
* reader's language (`say`, `language`; English by default): how it would be read, its tokens,
|
|
325
|
+
* and US dollars at list prices, or why it would add nothing. A self-hosted model's has no price,
|
|
326
|
+
* but how many articles its context holds, and how long it would take at the speed it last
|
|
327
|
+
* answered at.
|
|
326
328
|
*/
|
|
327
329
|
export async function estimate(options) {
|
|
328
330
|
const { settings, provider } = options;
|
|
331
|
+
const say = options.say ?? english;
|
|
332
|
+
const language = options.language ?? 'en';
|
|
329
333
|
const plan = planOf(options.input, settings, options.userSettings, provider.capacity);
|
|
330
334
|
if (!plan)
|
|
331
|
-
return
|
|
335
|
+
return say('text.estimate.nothing');
|
|
332
336
|
const tokens = tokensIn(plan.planned);
|
|
333
337
|
const left = await remaining({ instance: settings.monthlyTokens, user: settings.userMonthlyTokens }, { instance: options.storage, user: options.userStorage }, options.now());
|
|
334
|
-
const formatted = (n) =>
|
|
338
|
+
const formatted = (n) => numbers(language).format(n);
|
|
335
339
|
const count = plan.entries.length;
|
|
336
|
-
const
|
|
337
|
-
|
|
340
|
+
const sized = {
|
|
341
|
+
articles: counted(say, 'text.count.articles', count, language),
|
|
342
|
+
requests: counted(say, 'text.count.requests', plan.planned.length, language),
|
|
343
|
+
model: provider.label,
|
|
344
|
+
tokens: formatted(tokens),
|
|
345
|
+
};
|
|
338
346
|
if (left < tokens)
|
|
339
|
-
return
|
|
347
|
+
return say('text.estimate.overBudget', { ...sized, left: formatted(left) });
|
|
340
348
|
const { capacity } = provider;
|
|
341
349
|
if (capacity.kind === 'grow')
|
|
342
|
-
return
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
350
|
+
return say('text.estimate.claude', {
|
|
351
|
+
...sized,
|
|
352
|
+
cost: dollars(costOf(settings.model, plan.planned, premiumOf(settings)), say, language),
|
|
353
|
+
});
|
|
354
|
+
const sentences = [say('text.estimate.selfHosted', sized)];
|
|
355
|
+
if (count < plan.chosen)
|
|
356
|
+
sentences.push(say(`text.estimate.held.${plan.maxParts === 1 ? 'one' : 'other'}`, {
|
|
357
|
+
count: formatted(count),
|
|
358
|
+
chosen: formatted(plan.chosen),
|
|
359
|
+
context: formatted(capacity.contextTokens),
|
|
360
|
+
parts: formatted(plan.maxParts),
|
|
361
|
+
}));
|
|
346
362
|
const speed = await speedOf(options.storage);
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
: ''}.`;
|
|
355
|
-
return `A test digest now: ${articles} in ${requests} to ${provider.label}, about ${formatted(tokens)} tokens${held}. It runs on your own server, at no charge per token.${time}`;
|
|
363
|
+
if (speed) {
|
|
364
|
+
const minutes = Math.max(1, Math.round(secondsAt(speed, plan.planned, provider.parallel) / 60));
|
|
365
|
+
sentences.push(counted(say, 'text.estimate.minutes', minutes, language));
|
|
366
|
+
if (minutes * 60 > DIGEST_LIMITS.timeoutSeconds)
|
|
367
|
+
sentences.push(say('text.estimate.tooLong', { limit: formatted(DIGEST_LIMITS.timeoutSeconds / 60) }));
|
|
368
|
+
}
|
|
369
|
+
return sentences.join(' ');
|
|
356
370
|
}
|
|
357
371
|
const nothing = (outcome) => ({ overview: null, sections: null, outcome });
|
|
358
372
|
/**
|
|
@@ -463,7 +477,7 @@ export async function compose(options) {
|
|
|
463
477
|
parts: parts.length,
|
|
464
478
|
timedOut: missed.filter((outcome) => outcome === 'timed out').length,
|
|
465
479
|
failed: missed.filter((outcome) => outcome !== 'timed out').length,
|
|
466
|
-
});
|
|
480
|
+
}, options.say, input.language);
|
|
467
481
|
return {
|
|
468
482
|
overview: additions.overview ? withNote(additions.overview, note) : note,
|
|
469
483
|
sections: additions.sections,
|
|
@@ -483,15 +497,18 @@ async function pooled(items, size, run) {
|
|
|
483
497
|
await Promise.all(Array.from({ length: Math.max(1, Math.min(size, items.length)) }, worker));
|
|
484
498
|
return results;
|
|
485
499
|
}
|
|
486
|
-
/** What an overview written from only some parts says of the rest. */
|
|
487
|
-
export function missingNote(counts) {
|
|
488
|
-
const n = (count) =>
|
|
500
|
+
/** What an overview written from only some parts says of the rest, in the digest's language. */
|
|
501
|
+
export function missingNote(counts, say = english, language = 'en') {
|
|
502
|
+
const n = (count) => numbers(language).format(count);
|
|
489
503
|
const { timedOut, failed } = counts;
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
504
|
+
const key = timedOut > 0 && failed > 0 ? 'both' : timedOut > 0 ? 'timedOut' : 'failed';
|
|
505
|
+
return say(`text.partial.${key}`, {
|
|
506
|
+
read: n(counts.read),
|
|
507
|
+
given: n(counts.given),
|
|
508
|
+
parts: n(counts.parts),
|
|
509
|
+
timedOut: n(timedOut),
|
|
510
|
+
failed: n(failed),
|
|
511
|
+
});
|
|
495
512
|
}
|
|
496
513
|
/** The overview with a last paragraph, within the digest's limit. */
|
|
497
514
|
const withNote = (overview, note) => `${overview.slice(0, DIGEST_LIMITS.overview - note.length - 2).trimEnd()}\n\n${note}`;
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { compose, estimate } from './digest.js';
|
|
|
3
3
|
import { providerFor } from './providers/index.js';
|
|
4
4
|
import { API_HOST } from './providers/anthropic.js';
|
|
5
5
|
import { BEDROCK_HOST_REGIONS, bedrockHost } from './providers/bedrock.js';
|
|
6
|
+
import { MESSAGES, numbers } from './messages.js';
|
|
6
7
|
import { instanceSettings, userSettings } from './settings.js';
|
|
7
8
|
import { usedThisMonth } from './usage.js';
|
|
8
9
|
/** Of the digest's time, what is left unused, for counting what came back. */
|
|
9
10
|
const MARGIN_MS = 3_000;
|
|
10
|
-
const formatted = (tokens) => new Intl.NumberFormat('en').format(tokens);
|
|
11
11
|
/** The host a self-hosted Ollama has on the Docker network of the plugin's compose example. */
|
|
12
12
|
const OLLAMA_HOST = 'ollama';
|
|
13
13
|
/**
|
|
@@ -20,89 +20,18 @@ const OLLAMA_HOST = 'ollama';
|
|
|
20
20
|
export default definePlugin({
|
|
21
21
|
id: 'digest-summary',
|
|
22
22
|
// Keep in step with package.json; a test checks they match.
|
|
23
|
-
version: '0.
|
|
24
|
-
|
|
23
|
+
version: '0.4.0',
|
|
24
|
+
// context.language and context.message arrived in plugin API 0.1.4.
|
|
25
|
+
apiVersion: '^0.1.4',
|
|
25
26
|
scopes: ['user'],
|
|
26
27
|
hosts: [API_HOST, ...BEDROCK_HOST_REGIONS.map(bedrockHost), OLLAMA_HOST],
|
|
27
28
|
settings: { instance: instanceSettings, user: userSettings },
|
|
28
|
-
messages:
|
|
29
|
-
en: {
|
|
30
|
-
name: 'Digest summary',
|
|
31
|
-
description: 'Opens your email digest with an overview of what your unread articles are about, written by an AI model: a lead on their common themes, then topic sections whose points link the articles they draw on. The title, feed name, and first lines of the unread articles of the feeds you choose go, with your sections and instructions, to the model the server’s admin chose: Claude through Anthropic (api.anthropic.com), with the server’s API key under Anthropic’s commercial terms; Claude through Amazon Bedrock (bedrock-runtime.REGION.amazonaws.com, in the region the admin set), with the server’s Bedrock API key under that AWS account’s terms; or a model the server’s operator runs, at the address the admin set. Articles from feeds with a login, and pages you published, are never sent, nor are links.',
|
|
32
|
-
'settings.provider': 'Model from',
|
|
33
|
-
'settings.provider.hint': 'Anthropic bills each request to the API key, and Amazon Bedrock to the AWS account of its API key. A self-hosted model runs on a server you run, such as the Ollama of the plugin’s Docker example. Each needs its host approved above.',
|
|
34
|
-
'settings.provider.option.anthropic': 'Anthropic (Claude)',
|
|
35
|
-
'settings.provider.option.bedrock': 'Amazon Bedrock (Claude)',
|
|
36
|
-
'settings.provider.option.ollama': 'Ollama, self-hosted',
|
|
37
|
-
'settings.provider.option.openai': 'Self-hosted server with the OpenAI API (llama.cpp, vLLM, LM Studio…)',
|
|
38
|
-
'settings.apiKey': 'Anthropic API key',
|
|
39
|
-
'settings.apiKey.hint': 'From the Claude Console (platform.claude.com), under API keys: every request is billed to it. Sent only to Anthropic. Stored as a secret.',
|
|
40
|
-
'settings.model': 'Claude model',
|
|
41
|
-
'settings.model.hint': 'Opus writes best, Haiku costs least. The same models on Bedrock.',
|
|
42
|
-
'settings.model.option.claude-opus-5-5': 'Claude Opus 5.5',
|
|
43
|
-
'settings.model.option.claude-sonnet-5-5': 'Claude Sonnet 5.5',
|
|
44
|
-
'settings.model.option.claude-haiku-5-5': 'Claude Haiku 5.5',
|
|
45
|
-
'settings.effort': 'Claude effort',
|
|
46
|
-
'settings.effort.hint': 'How much Claude thinks before it writes; more costs more tokens and takes longer, and a digest waits at most five minutes.',
|
|
47
|
-
'settings.effort.option.low': 'Low',
|
|
48
|
-
'settings.effort.option.medium': 'Medium',
|
|
49
|
-
'settings.effort.option.high': 'High',
|
|
50
|
-
'settings.bedrockApiKey': 'Bedrock API key',
|
|
51
|
-
'settings.bedrockApiKey.hint': 'A long-term Amazon Bedrock API key, from the Bedrock console (API keys) or the IAM user it belongs to, which needs bedrock:InvokeModel and bedrock:CallWithBearerToken: every request is billed to its AWS account. Give it an expiry and replace it before then. Sent only to Bedrock. Stored as a secret.',
|
|
52
|
-
'settings.bedrockRegion': 'Bedrock region',
|
|
53
|
-
'settings.bedrockRegion.hint': 'The AWS region requests are sent to, such as us-east-1 or eu-west-1. Approve its host above: bedrock-runtime.REGION.amazonaws.com.',
|
|
54
|
-
'settings.bedrockRouting': 'Bedrock routing',
|
|
55
|
-
'settings.bedrockRouting.hint': 'Where Bedrock may run each request. Within the region’s geography (the US, which includes Canada’s regions, the EU, Australia, or Japan) costs 10% more.',
|
|
56
|
-
'settings.bedrockRouting.option.global': 'Any region worldwide',
|
|
57
|
-
'settings.bedrockRouting.option.geography': 'Within the region’s geography',
|
|
58
|
-
'settings.baseUrl': 'Self-hosted server’s URL',
|
|
59
|
-
'settings.baseUrl.hint': 'Ollama’s, such as http://ollama:11434; or the OpenAI API’s, ending in /v1, such as http://llama:8080/v1. Its host must be approved above, and, on a private network, listed in the server’s PLUGIN_TRUSTED_HOSTS.',
|
|
60
|
-
'settings.localApiKey': 'Self-hosted server’s key',
|
|
61
|
-
'settings.localApiKey.hint': 'Only if the server asks for one, such as a server with the OpenAI API started with a key, or an Ollama behind a proxy that checks a bearer token. Sent as a bearer token. Stored as a secret.',
|
|
62
|
-
'settings.localModel': 'Self-hosted model',
|
|
63
|
-
'settings.localModel.hint': 'As the server names it, such as qwen3:8b on Ollama. Pull it there first; Send test checks it.',
|
|
64
|
-
'settings.contextTokens': 'Context, in tokens',
|
|
65
|
-
'settings.contextTokens.hint': 'What the model reads and writes in one request: the newest articles that fit are read, in up to 6 requests and one more for the overview. Sent to Ollama with each request; a server with the OpenAI API must be started with at least this much (llama.cpp’s -c). More reads more articles, takes more memory, and takes longer.',
|
|
66
|
-
'settings.parallelRequests': 'Requests at once',
|
|
67
|
-
'settings.parallelRequests.hint': 'Parts of a large digest read together. Keep to what the server runs at once (Ollama’s OLLAMA_NUM_PARALLEL), or they wait their turn.',
|
|
68
|
-
'settings.thinking': 'Let the self-hosted model think first',
|
|
69
|
-
'settings.thinking.hint': 'For Ollama models that think, such as Qwen 3: the model thinks before writing the overview (parts of a large digest are read without), from the answer’s room and time, so overviews take longer. Off by default, which writes faster.',
|
|
70
|
-
'settings.monthlyTokens': 'Tokens a month, for the server',
|
|
71
|
-
'settings.monthlyTokens.hint': 'Once used, no more overviews are written until the month ends (UTC). Self-hosted models count too. Send test shows how many are used.',
|
|
72
|
-
'settings.userMonthlyTokens': 'Tokens a month, for each user',
|
|
73
|
-
'settings.userMonthlyTokens.hint': 'A digest of 1,000 unread articles reads about 100,000 tokens.',
|
|
74
|
-
'settings.allowInstructions': 'Users may add their own instructions',
|
|
75
|
-
'settings.allowInstructions.hint': 'When off, the instructions users wrote under For me are kept but not sent.',
|
|
76
|
-
'settings.feedChoice': 'Feeds to read',
|
|
77
|
-
'settings.feedChoice.option.all': 'All my feeds',
|
|
78
|
-
'settings.feedChoice.option.only': 'Only the feeds below',
|
|
79
|
-
'settings.feedChoice.option.except': 'All but the feeds below',
|
|
80
|
-
'settings.feeds': 'Feeds',
|
|
81
|
-
'settings.feeds.hint': 'Used when only some feeds are read, or all but some.',
|
|
82
|
-
'settings.sections': 'Sections',
|
|
83
|
-
'settings.sections.hint': 'The topics stories are sorted into, in this order; sections nothing fits are left out. Name a section in any language: its heading is written in your digest’s. With none, the default sections are used.',
|
|
84
|
-
'settings.sections.item.name': 'Name',
|
|
85
|
-
'settings.sections.item.about': 'What goes in it',
|
|
86
|
-
'settings.length': 'Length',
|
|
87
|
-
'settings.length.hint': 'Longer overviews cost more tokens.',
|
|
88
|
-
'settings.length.option.brief': 'Brief: up to 2 short points a section',
|
|
89
|
-
'settings.length.option.standard': 'Standard: up to 3 points a section',
|
|
90
|
-
'settings.length.option.detailed': 'Detailed: up to 5 longer points a section',
|
|
91
|
-
'settings.style': 'Points shown as',
|
|
92
|
-
'settings.style.option.paragraphs': 'Paragraphs',
|
|
93
|
-
'settings.style.option.bullets': 'Bullets',
|
|
94
|
-
'settings.lead': 'Open with a lead on the common themes',
|
|
95
|
-
'settings.instructions': 'Your instructions',
|
|
96
|
-
'settings.instructions.hint': 'What to focus on, leave out, or how to write, such as “Skip celebrity news; explain jargon.” Up to 1,000 characters, sent to the model with your articles. They cannot change what is sent or the overview’s format.',
|
|
97
|
-
'action.estimate': 'Estimate cost',
|
|
98
|
-
'action.estimate.hint': 'What the overview of a test digest of your unread articles from the last day would read and cost now, and with a self-hosted model how long it would take, without sending it.',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
29
|
+
messages: MESSAGES,
|
|
101
30
|
hooks: {
|
|
102
31
|
'digest.compose': {
|
|
103
32
|
async run(input, context) {
|
|
104
33
|
const started = Date.now();
|
|
105
|
-
const provider = providerFor(context.settings, context.fetch);
|
|
34
|
+
const provider = providerFor(context.settings, context.fetch, context.message, context.language);
|
|
106
35
|
const { overview, sections, outcome } = await compose({
|
|
107
36
|
provider,
|
|
108
37
|
settings: context.settings,
|
|
@@ -114,6 +43,7 @@ export default definePlugin({
|
|
|
114
43
|
signal: context.signal,
|
|
115
44
|
deadline: started + DIGEST_LIMITS.timeoutSeconds * 1000 - MARGIN_MS,
|
|
116
45
|
now: () => new Date(),
|
|
46
|
+
say: context.message,
|
|
117
47
|
});
|
|
118
48
|
context.logger.info('digest composed', { outcome, provider: provider.name });
|
|
119
49
|
return { overview, sections };
|
|
@@ -121,15 +51,22 @@ export default definePlugin({
|
|
|
121
51
|
},
|
|
122
52
|
test: {
|
|
123
53
|
async run(context) {
|
|
124
|
-
const checked = await providerFor(context.settings, context.fetch).check(context.signal);
|
|
54
|
+
const checked = await providerFor(context.settings, context.fetch, context.message, context.language).check(context.signal);
|
|
125
55
|
if (!checked.ok)
|
|
126
56
|
return checked;
|
|
127
57
|
const now = new Date();
|
|
128
58
|
const server = await usedThisMonth(context.storage, now);
|
|
129
59
|
const mine = context.userStorage ? await usedThisMonth(context.userStorage, now) : 0;
|
|
60
|
+
const formatted = (tokens) => numbers(context.language).format(tokens);
|
|
130
61
|
return {
|
|
131
62
|
ok: true,
|
|
132
|
-
message:
|
|
63
|
+
message: context.message('text.test.usage', {
|
|
64
|
+
checked: checked.message,
|
|
65
|
+
mine: formatted(mine),
|
|
66
|
+
myLimit: formatted(context.settings.userMonthlyTokens),
|
|
67
|
+
server: formatted(server),
|
|
68
|
+
serverLimit: formatted(context.settings.monthlyTokens),
|
|
69
|
+
}),
|
|
133
70
|
};
|
|
134
71
|
},
|
|
135
72
|
},
|
|
@@ -142,15 +79,17 @@ export default definePlugin({
|
|
|
142
79
|
ok: true,
|
|
143
80
|
message: digest
|
|
144
81
|
? await estimate({
|
|
145
|
-
provider: providerFor(context.settings, context.fetch),
|
|
82
|
+
provider: providerFor(context.settings, context.fetch, context.message, context.language),
|
|
146
83
|
settings: context.settings,
|
|
147
84
|
userSettings: context.userSettings ?? userSettings.parse({}),
|
|
148
85
|
input: digest,
|
|
149
86
|
storage: context.storage,
|
|
150
87
|
userStorage: context.userStorage,
|
|
151
88
|
now: () => new Date(),
|
|
89
|
+
say: context.message,
|
|
90
|
+
language: context.language,
|
|
152
91
|
})
|
|
153
|
-
: '
|
|
92
|
+
: context.message('text.estimate.noDigest'),
|
|
154
93
|
}),
|
|
155
94
|
},
|
|
156
95
|
},
|