Skip to content

Conversation

@Yukimagi
Copy link

Description

This PR fixes a bug in ChatGPTLoader where the last message in the conversation was being dropped when using the default initialization arguments.

The Bug:
The __init__ method had a default value of num_logs=-1. In the load method, the code used slicing data[:self.num_logs] when num_logs was truthy. Since -1 is truthy, this resulted in data[:-1], which excluded the last element of the list.

The Fix:
Changed the default value of num_logs to 0 (which implies loading all logs), ensuring the slicing logic correctly handles the default case.

Testing:

  • Added a new test file tests/unit_tests/document_loaders/test_chatgpt.py.
  • Added unit tests to verify correct loading of conversation data.
  • Verified that num_logs parameter works as expected.
  • Coverage: Increased code coverage for chatgpt.py from 0% to 100%.

Issue

Fixes #465

Dependencies

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: ChatGPTLoader misses the last message when loading default logs

1 participant