@molecule/api-ai-summarization-llm 1.1.0 → 1.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,gCAAgC,CAAA;AAgEvC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,uBA8BtB,CAAA;AASD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAS9D"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,gCAAgC,CAAA;AAgEvC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,uBA8BtB,CAAA;AASD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAehD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAS9D"}
package/dist/provider.js CHANGED
@@ -117,6 +117,15 @@ export function cleanSummary(raw) {
117
117
  s = s.replace(/\s+/g, ' ').trim();
118
118
  s = s.replace(/^(?:\*\*)?(?:tl;?\s?dr|summary)(?:\*\*)?\s*[:\-–—]\s*/i, '');
119
119
  s = s.replace(/^(\*\*|__|["“'‘])+/, '').replace(/(\*\*|__|["”'’])+$/, '');
120
+ // A summary is plain text: markdown the model added (`code`, **bold**, _em_,
121
+ // [links](url)) would show literally wherever the summary is displayed.
122
+ s = s
123
+ .replace(/`([^`]*)`/g, '$1')
124
+ .replace(/\*\*([^*]+)\*\*/g, '$1')
125
+ .replace(/__([^_]+)__/g, '$1')
126
+ .replace(/(^|[\s(])[*_]([^*_\s][^*_]*?)[*_](?=[\s).,;:!?]|$)/g, '$1$2')
127
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
128
+ .replace(/`/g, '');
120
129
  return s.trim();
121
130
  }
122
131
  /**
@@ -171,8 +180,11 @@ async function summarizeCapped(ai, input, sentences) {
171
180
  const cap = input.maxWords;
172
181
  const attempts = Math.max(1, input.attempts ?? 3);
173
182
  const shape = sentences === 1 ? 'one sentence' : `at most ${sentences} sentences`;
183
+ // Models treat a stated maximum as the target and land on it exactly, so ask
184
+ // for a length well under the cap; the cap itself is enforced below.
185
+ const target = cap ? Math.max(5, Math.round(cap * 0.7)) : undefined;
174
186
  const system = [
175
- `Summarize the user's text in ${shape}${cap ? ` of at most ${cap} words in total` : ''}, stating what the text does or says.`,
187
+ `Summarize the user's text in ${shape}${cap ? ` of about ${target} words (never more than ${cap})` : ''}, stating what the text does or says.`,
176
188
  input.focus ? `Focus on: ${input.focus}` : '',
177
189
  'Reply with the summary only: no preamble, no label, no quotes, no markdown.',
178
190
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai-summarization-llm",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Default LLM-composed AI summarization provider for molecule.dev — summarizes over any bonded @molecule/api-ai chat provider",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",