Skip to content

Conversation

danny-avila
Copy link
Owner

Summary

Closes #9505
Closes #9491

I fixed bugs in the ChatGPT import functionality that were causing incorrect sender assignment and broken conversation flows when encountering system messages.

  • Fixed sender assignment logic to ensure user messages always maintain 'user' sender regardless of GPT model metadata
  • Implemented findNonSystemParent helper function to traverse parent hierarchy and skip system messages when establishing parent-child relationships
  • Added comprehensive test coverage for both fixes including edge cases with GPT-4 models and system messages interrupting conversation flows
  • Updated logger import to use data-schemas module for consistency
  • Ensured message graph integrity is preserved during import process even when system messages exist between user and assistant messages

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

I added comprehensive unit tests that verify the fixes work correctly:

Test Configuration:

Sender Assignment Test: Validates that user messages retain 'user' sender and assistant messages get correct GPT-4/GPT-3.5 sender based on model, covering multiple model types (gpt-4, gpt-4o-mini, gpt-3.5-turbo).

System Message Handling Test: Creates a conversation with a system message between assistant and user messages, then verifies the parent-child relationships remain intact by checking that the second user message correctly references the first assistant message as its parent rather than being orphaned.

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

…ystem message

- Implemented `findNonSystemParent` to maintain parent-child relationships by skipping system messages.
- Added a test case to ensure system messages do not disrupt the conversation flow during import.
…rocess

- Updated sender assignment logic to dynamically extract model names from model slugs, improving accuracy for various GPT models.
- Added comprehensive tests to validate the extraction and formatting of model names from different model slugs, ensuring robustness in the import functionality.
@danny-avila danny-avila merged commit 519645c into dev Sep 9, 2025
5 checks passed
@danny-avila danny-avila deleted the fix/chatgpt-imports branch September 9, 2025 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant