-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Add ability to parse code #293
base: main
Are you sure you want to change the base?
Conversation
cd97b07
to
9553860
Compare
@santib This opens up an interesting problem -- how do we chunk code? |
Yeah, I just used the Text one for simplicity, but checking https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/code_splitter seems like they get the separators for each language, and that's it. I can change this PR to do something similar if you want |
@santib Yeah, I like that! |
9553860
to
1e70bc7
Compare
1e70bc7
to
dc52a2a
Compare
def chunks(options = {}) | ||
if Langchain::Processors::Code::EXTENSIONS.include?(source_type) | ||
options = options.merge(separators: Langchain::Chunker::Base::LANG_SEPARATORS[source_type]) | ||
Langchain::Chunker::RecursiveText.new(@data, **options).chunks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add tests
Something like this is needed so we can load codebases in Vector DBs