Skip to content

Commit

Permalink
Update chat parsing logic to include only the most recent 10 messages
Browse files Browse the repository at this point in the history
  • Loading branch information
schleising committed Aug 27, 2024
1 parent 7cc5a63 commit 467c3c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/simple_openai/chat_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def get_chat(self, chat_id: str = DEFAULT_CHAT_ID) -> str:
# Get the chat
chat = self._messages[chat_id]

# Parse the chat to a string with each name and message on a new line
# Parse the most recent 10 chat messages to a string with each name and message on a new line
chat_str = "\n".join(
[f"{message.name}: {message.content}" for message in chat]
[f"{message.name}: {message.content}" for message in list(chat)[-10:]]
)

# Return the chat
Expand Down

0 comments on commit 467c3c3

Please sign in to comment.