From 0a5b5c3fd67ce86f101ca8cc88d2cd5d2cd364e3 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 7 Aug 2024 13:13:10 -0300 Subject: [PATCH] fix: Fix token_count method to handle list of messages --- aider/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aider/models.py b/aider/models.py index f2fb3b458..908404343 100644 --- a/aider/models.py +++ b/aider/models.py @@ -528,6 +528,9 @@ class Model: return litellm.encode(model=self.name, text=text) def token_count(self, messages): + if type(messages) is list: + return litellm.token_counter(model=self.name, messages=messages) + if not self.tokenizer: return