-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[DRAFT] Chunker .add API #2261
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
Draft
atroyn
wants to merge
1
commit into
05-29-anton_chunker
Choose a base branch
from
05-29-chunker_.add_api
base: 05-29-anton_chunker
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[DRAFT] Chunker .add API #2261
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[['This is a test of the chunker. It should chunk this text into a list of',\n", | ||
" 'sentences. This is the first sentence. This is the second sentence.',\n", | ||
" 'Folks, this example has so many beautiful sentences. I love it.',\n", | ||
" 'You guys. The test. Ten thousand blistering blue barnacles.',\n", | ||
" \"It's great.\\n\\n\\nIt's the best example ever. I'm so happy to be working on this.\"]]" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from chromadb.utils.chunkers.default_chunker import DefaultTextChunker\n", | ||
"\n", | ||
"chunker = DefaultTextChunker()\n", | ||
"\n", | ||
"test_text = \"\"\"\n", | ||
"This is a test of the chunker. It should chunk this text into a list of\n", | ||
"sentences. This is the first sentence. This is the second sentence.\n", | ||
"\n", | ||
"\n", | ||
"Folks, this example has so many beautiful sentences. I love it.\n", | ||
"You guys. The test. Ten thousand blistering blue barnacles.\n", | ||
"\n", | ||
"It's great.\n", | ||
"\n", | ||
"\n", | ||
"It's the best example ever. I'm so happy to be working on this.\n", | ||
"\"\"\"\n", | ||
"\n", | ||
"chunker([test_text], max_chunk_size=100)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'ids': ['test_id_0', 'test_id_1', 'test_id_2', 'test_id_3', 'test_id_4'],\n", | ||
" 'embeddings': None,\n", | ||
" 'metadatas': [None, None, None, None, None],\n", | ||
" 'documents': ['This is a test of the chunker. It should chunk this text into a list of',\n", | ||
" 'sentences. This is the first sentence. This is the second sentence.',\n", | ||
" 'Folks, this example has so many beautiful sentences. I love it.',\n", | ||
" 'You guys. The test. Ten thousand blistering blue barnacles.',\n", | ||
" \"It's great.\\n\\n\\nIt's the best example ever. I'm so happy to be working on this.\"],\n", | ||
" 'uris': None,\n", | ||
" 'data': None,\n", | ||
" 'included': ['metadatas', 'documents']}" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import chromadb\n", | ||
"\n", | ||
"client = chromadb.Client()\n", | ||
"collection = client.get_or_create_collection('test_collection')\n", | ||
"\n", | ||
"collection.add(ids=['test_id'], documents=[test_text], chunker=DefaultTextChunker(max_chunk_size=100))\n", | ||
"\n", | ||
"collection.get()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "chroma", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Basically we expand the list of IDs by chunk ID. We should probably pass these out to the user (we currently do not pass IDs out) so they can keep track of the new IDs. I can do that here, on in a separate PR.