Fix truncation calculation
This commit is contained in:
parent
0317b2f5aa
commit
48f13fcf7f
1 changed files with 2 additions and 4 deletions
|
@ -921,7 +921,7 @@ class GPTBot:
|
||||||
|
|
||||||
chat_messages = [{"role": "system", "content": system_message}]
|
chat_messages = [{"role": "system", "content": system_message}]
|
||||||
|
|
||||||
last_messages = [event] + last_messages
|
last_messages = last_messages + [event]
|
||||||
|
|
||||||
for message in last_messages:
|
for message in last_messages:
|
||||||
if isinstance(message, (RoomMessageNotice, RoomMessageText)):
|
if isinstance(message, (RoomMessageNotice, RoomMessageText)):
|
||||||
|
@ -953,7 +953,7 @@ class GPTBot:
|
||||||
|
|
||||||
# Truncate messages to fit within the token limit
|
# Truncate messages to fit within the token limit
|
||||||
truncated_messages = self._truncate(
|
truncated_messages = self._truncate(
|
||||||
chat_messages, self.max_tokens - 1, system_message=system_message
|
chat_messages[1:], self.max_tokens - 1, system_message=system_message
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -978,8 +978,6 @@ class GPTBot:
|
||||||
|
|
||||||
self.logger.log(f"Sending response to room {room.room_id}...")
|
self.logger.log(f"Sending response to room {room.room_id}...")
|
||||||
|
|
||||||
# Convert markdown to HTML
|
|
||||||
|
|
||||||
message = await self.send_message(room, response)
|
message = await self.send_message(room, response)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue