From 7dc8a90a26364b408a3d06c4f4fcbfde068b6e0a Mon Sep 17 00:00:00 2001 From: smathot Date: Fri, 26 Jul 2024 16:55:29 +0200 Subject: [PATCH] Ignore large tool results when condensing message history --- sigmund/__init__.py | 2 +- sigmund/messages.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sigmund/__init__.py b/sigmund/__init__.py index 73cab76..80f49b2 100644 --- a/sigmund/__init__.py +++ b/sigmund/__init__.py @@ -1,3 +1,3 @@ """AI-based chatbot that provides sensible answers based on documentation""" -__version__ = '0.24.4' +__version__ = '0.24.5' diff --git a/sigmund/messages.py b/sigmund/messages.py index 7a138a3..1bd1fbc 100644 --- a/sigmund/messages.py +++ b/sigmund/messages.py @@ -146,6 +146,9 @@ def _condense_message_history(self): condense_messages = [] while condense_length < config.condense_chunk_length: role, content = self._condensed_message_history.pop(0) + if role == 'tool' and \ + len(content) > config.large_tool_result_length: + continue condense_length += len(content) condense_messages.insert(0, (role, content)) logger.info(f'condensing {len(condense_messages)} messages')