llm-fns 1.0.4 → 1.0.5

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.
@@ -141,12 +141,17 @@ function getPromptSummary(messages) {
141
141
  const fullText = concatMessageText(messages);
142
142
  // Replace multiple whitespace chars with a single space and trim.
143
143
  const cleanedText = fullText.replace(/\s+/g, ' ').trim();
144
- // Truncate to a reasonable length.
145
- const maxLength = 150;
146
- if (cleanedText.length > maxLength) {
147
- return cleanedText.substring(0, maxLength) + '...';
144
+ if (cleanedText.length <= 50) {
145
+ return cleanedText;
148
146
  }
149
- return cleanedText;
147
+ const partLength = 15;
148
+ const start = cleanedText.substring(0, partLength);
149
+ const end = cleanedText.substring(cleanedText.length - partLength);
150
+ const midIndex = Math.floor(cleanedText.length / 2);
151
+ const midStart = Math.max(partLength, midIndex - Math.ceil(partLength / 2));
152
+ const midEnd = Math.min(cleanedText.length - partLength, midStart + partLength);
153
+ const middle = cleanedText.substring(midStart, midEnd);
154
+ return `${start}...${middle}...${end}`;
150
155
  }
151
156
  function normalizeOptions(arg1, arg2) {
152
157
  if (typeof arg1 === 'string') {
@@ -229,7 +234,7 @@ function createLlmClient(params) {
229
234
  }
230
235
  return true;
231
236
  });
232
- const response = (await (queue ? queue.add(task, { id: promptSummary }) : task()));
237
+ const response = (await (queue ? queue.add(task, { id: promptSummary, messages: finalMessages }) : task()));
233
238
  if (cacheInstance && response && cacheKey) {
234
239
  try {
235
240
  await cacheInstance.set(cacheKey, JSON.stringify(response), ttl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-fns",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",