Hacker News new | ask | show | jobs
by upwardbound 1046 days ago
In your loop:

            for m in reversed(self.messages):
                if total_tokens + m.length <= max_tokens:
                    recent_messages_reversed.append({
                        "role": m.role,
                        "content": m.text
                    })
                    total_tokens += m.length
                else:
                    break
It would be important to change that to not drop system prompts, ever. Otherwise a user can defeat the system prompt simply by providing enough user messages.
1 comments

Good point. The way I use it though is to always add the system prompt to the front after calling that function.