diff --git a/packages/client-discord/src/actions/chat_with_attachments.ts b/packages/client-discord/src/actions/chat_with_attachments.ts index 607955fb67..61163651d9 100644 --- a/packages/client-discord/src/actions/chat_with_attachments.ts +++ b/packages/client-discord/src/actions/chat_with_attachments.ts @@ -1,5 +1,6 @@ import { composeContext } from "@elizaos/core"; import { generateText, trimTokens } from "@elizaos/core"; +import type { TiktokenModel } from "js-tiktoken"; import { models } from "@elizaos/core"; import { parseJSONObjectFromText } from "@elizaos/core"; import { @@ -194,10 +195,12 @@ const summarizeAction = { const context = composeContext({ state, // make sure it fits, we can pad the tokens a bit + // Get the model's tokenizer based on the current model being used template: trimTokens( summarizationTemplate, chunkSize + 500, - "gpt-4o-mini" // TODO: make this dynamic and generic + (model.model[ModelClass.SMALL] || + "gpt-4o-mini") as TiktokenModel // Use the same model as generation; Fallback if no SMALL model configured ), });