diff --git a/package.json b/package.json index 0ad25ce..4e7c18d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/ai-utils", - "version": "0.8.14", + "version": "0.8.15", "description": "AI Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/llm.ts b/src/llm.ts index 7b0faa9..8a1f20c 100644 --- a/src/llm.ts +++ b/src/llm.ts @@ -387,12 +387,12 @@ class LLM { /** * Create a summary of some text * @param {string} text Text to summarize - * @param {number} tokens Max number of tokens + * @param {number} length Max number of words * @param options LLM request options * @returns {Promise} Summary */ - async summarize(text: string, tokens: number = 500, options?: LLMRequest): Promise { - let system = `Your job is to summarize the users message using tool calls. Call the \`submit\` tool at least once with the shortest summary possible that's <= ${tokens} tokens. The tool call will respond with the token count. Responses are ignored`; + async summarize(text: string, length: number = 500, options?: LLMRequest): Promise { + let system = `Your job is to summarize the users message using tool calls. Call the \`submit\` tool at least once with the shortest summary possible that's <= ${length} words. The tool call will respond with the token count. Responses are ignored`; if(options?.system) system += '\n\n' + options.system; return new Promise(async (resolve, reject) => { let done = false; @@ -406,11 +406,11 @@ class LLM { args: {summary: {type: 'string', description: 'Text summarization', required: true}}, fn: (args) => { if(!args.summary) return 'No summary provided'; - const count = this.estimateTokens(args.summary); - if(count > tokens) return `Summary is too long (${count} tokens)`; + const count = args.summary.split(' ').length; + if(count > length) return `Too long: ${length} words`; done = true; resolve(args.summary || null); - return `Saved (${count} tokens)`; + return `Saved: ${length} words`; } }, ...(options?.tools || [])], });