Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-splitters: Add JSFrameworkTextSplitter for Handling JavaScript Framework Code #28972

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

BenStuk
Copy link

@BenStuk BenStuk commented Dec 30, 2024

Description

This pull request introduces a new text splitter, JSFrameworkTextSplitter, to the Langchain library. The JSFrameworkTextSplitter extends the RecursiveCharacterTextSplitter to handle JavaScript framework code effectively, including React (JSX), Vue, and Svelte. It identifies and utilizes framework-specific component tags and syntax elements as splitting points, alongside standard JavaScript syntax. This ensures that code is divided at natural boundaries, enhancing the parsing and processing of JavaScript and framework-specific code.

Key Features

  • Supports React (JSX), Vue, and Svelte frameworks.
  • Identifies and uses framework-specific tags and syntax elements as natural splitting points.
  • Extends the existing RecursiveCharacterTextSplitter for seamless integration.

Issue

No specific issue addressed.

Dependencies

No additional dependencies required.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 30, 2024
Copy link

vercel bot commented Dec 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 5, 2025 1:26pm

@dosubot dosubot bot added the Ɑ: text splitters Related to text splitters package label Dec 30, 2024
Copy link
Collaborator

@ccurme ccurme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be implemented as a new case in the get_separators_for_language method?

@ccurme ccurme self-assigned this Jan 2, 2025
@ccurme ccurme marked this pull request as draft January 2, 2025 20:54
@BenStuk
Copy link
Author

BenStuk commented Jan 3, 2025

Can this be implemented as a new case in the get_separators_for_language method?

hi @ccurme, we need the special method to handle React component tags (such as <MyComponent>) in a dynamic way, a fixed list of separators wouldn't be able to recognize them.

@BenStuk BenStuk changed the title text-splitters: Add JSXTextSplitter for JSX/React Code Handling text-splitters: Add JSFrameworkTextSplitter for Handling JavaScript Framework Code Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files. Ɑ: text splitters Related to text splitters package
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants