forked from Unstructured-IO/unstructured-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Addition of Custom chunking logic #1
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
Open
Sameena-Thabassum
wants to merge
13
commits into
main
Choose a base branch
from
custom_chunking
base: main
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.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f85b532
Addition of Custom chunking logic
Sameena-Thabassum d76a366
Update constraints.in to have correct branch from unstructured main lib
Sameena-Thabassum d572032
Update base.in
Sameena-Thabassum 5711866
Update Dockerfile to include git in the image
Sameena-Thabassum 191c403
Update base.in
Sameena-Thabassum e90e2be
Update constraints.in
Sameena-Thabassum 8c9dabd
Remove personal github repo
Sameena-Thabassum 6ccefc9
Docker changes to mount unstructured
Sameena-Thabassum abd2574
Update Dockerfile
Sameena-Thabassum 2880739
Update Dockerfile
Sameena-Thabassum b486f7f
Change the image name
Sameena-Thabassum e434c63
Update Dockerfile
Sameena-Thabassum 251a20c
Revert "Update Dockerfile"
Sameena-Thabassum 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
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 |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ class GeneralFormParams(BaseModel): | |
| encoding: str | ||
| content_type: Optional[str] | ||
| hi_res_model_name: Optional[str] | ||
| chunking_model_name: Optional[str] | ||
| include_page_breaks: bool | ||
| pdf_infer_table_structure: bool | ||
| strategy: str | ||
|
|
@@ -37,6 +38,7 @@ class GeneralFormParams(BaseModel): | |
| overlap_all: bool | ||
| starting_page_number: Optional[int] = None | ||
| include_slide_notes: bool | ||
| custom_metadata: Optional[str] = None | ||
|
|
||
| @classmethod | ||
| def as_form( | ||
|
|
@@ -129,6 +131,15 @@ def as_form( | |
| ), | ||
| BeforeValidator(SmartValueParser[str]().value_or_first_element), | ||
| ] = None, | ||
| chunking_model_name: Annotated[ | ||
| Optional[str], | ||
| Form( | ||
| title="Chunking Model Name", | ||
| description="The name of a custom model used when the chunking strategy is set to 'custom'.", | ||
| example="yolox", | ||
| ), | ||
| BeforeValidator(SmartValueParser[str]().value_or_first_element), | ||
| ] = None, | ||
| include_page_breaks: Annotated[ | ||
| bool, | ||
| Form( | ||
|
|
@@ -178,11 +189,11 @@ def as_form( | |
| ] = False, | ||
| # -- chunking options -- | ||
| chunking_strategy: Annotated[ | ||
| Optional[Literal["by_title"]], | ||
| Optional[Literal["by_title", "custom"]], | ||
| Form( | ||
| title="Chunking Strategy", | ||
| description="Use one of the supported strategies to chunk the returned elements. Currently supports: by_title", | ||
| examples=["by_title"], | ||
| description="Use one of the supported strategies to chunk the returned elements. Currently supports: by_title, custom", | ||
| examples=["by_title", "custom"], | ||
| ), | ||
| ] = None, | ||
| combine_under_n_chars: Annotated[ | ||
|
|
@@ -258,6 +269,15 @@ def as_form( | |
| example=False, | ||
| ), | ||
| ] = True, | ||
| custom_metadata: Annotated[ | ||
| Optional[str], | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be dict then ? |
||
| Form( | ||
| title="Custom Metadata", | ||
| description="A dictionary containing custom metadata for the document or elements. ", | ||
| example="{'author': 'John Doe', 'keywords': ['AI', 'ML', 'data processing']}", | ||
| ), | ||
| BeforeValidator(SmartValueParser[dict]().value_or_first_element), | ||
| ] = None, | ||
| ) -> "GeneralFormParams": | ||
| return cls( | ||
| xml_keep_tags=xml_keep_tags, | ||
|
|
@@ -270,6 +290,7 @@ def as_form( | |
| content_type=content_type, | ||
| encoding=encoding, | ||
| hi_res_model_name=hi_res_model_name, | ||
| chunking_model_name=chunking_model_name, | ||
| include_page_breaks=include_page_breaks, | ||
| pdf_infer_table_structure=pdf_infer_table_structure, | ||
| strategy=strategy, | ||
|
|
@@ -286,4 +307,5 @@ def as_form( | |
| unique_element_ids=unique_element_ids, | ||
| starting_page_number=starting_page_number, | ||
| include_slide_notes=include_slide_notes, | ||
| custom_metadata=custom_metadata, | ||
| ) | ||
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
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 |
|---|---|---|
|
|
@@ -23,12 +23,17 @@ if [[ -n $MAX_LIFETIME_SECONDS ]]; then | |
| fi | ||
| fi | ||
|
|
||
| ${OPTIONAL_TIMEOUT} \ | ||
| uvicorn prepline_general.api.app:app \ | ||
| CMD="uvicorn prepline_general.api.app:app \ | ||
| --host $HOST \ | ||
| --port $PORT \ | ||
| --log-config logger_config.yaml \ | ||
| --host "$HOST" \ | ||
| --port "$PORT" \ | ||
| --workers "$WORKERS" \ | ||
| --workers $WORKERS" | ||
|
|
||
| if [[ -n "$OPTIONAL_TIMEOUT" ]]; then | ||
| $OPTIONAL_TIMEOUT $CMD | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we not be doing eval here too ? |
||
| else | ||
| eval $CMD | ||
| fi | ||
|
|
||
| echo "Server was shutdown" | ||
| [ -n "$MAX_LIFETIME_SECONDS" ] && echo "Reached timeout of $MAX_LIFETIME_SECONDS seconds" | ||
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
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.
is this string ?