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

Allow chunking map call to take in sublists of length 10 and support lists as inputs #939

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2293f5c
Update sweepai/utils/utils.py
sweep-nightly[bot] Aug 3, 2023
a4a787c
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
fc6d7f0
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
4fb7dcd
Update pyproject.toml
sweep-nightly[bot] Aug 3, 2023
62ba2da
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
32f3ba6
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
0d4a69b
sweep: Create GitHub Actions workflow for Poetry installa
sweep-nightly[bot] Aug 3, 2023
8c30593
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
e71902c
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
b4b753f
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
77157ae
Delete ci.yml
kevinlu1248 Aug 3, 2023
aa3aa3a
Revert file to previous commit
sweep-nightly[bot] Aug 3, 2023
bbee7ec
Update pyproject.toml
sweep-nightly[bot] Aug 3, 2023
35e10be
Update pyproject.toml
sweep-nightly[bot] Aug 3, 2023
799fec2
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
cc3b447
Update pyproject.toml
sweep-nightly[bot] Aug 3, 2023
fd95ddb
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
a13409e
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
3283b18
Revert file to previous commit
sweep-nightly[bot] Aug 3, 2023
165a78d
sweep: Create .github/workflows/ci.yml
sweep-nightly[bot] Aug 3, 2023
c25dd3e
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 3, 2023
f62fd99
Delete ci.yml
kevinlu1248 Aug 4, 2023
d7430ae
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 4, 2023
672c4a6
Update sweepai/utils/utils.py
sweep-nightly[bot] Aug 4, 2023
0c9e0a8
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 4, 2023
ea2d41a
Merge main into sweep/feature/chunking-map-support
sweep-nightly[bot] Aug 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Python Poetry CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.10
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Homepage = "https://sweep.dev"

[tool.poetry.dependencies]
python = "^3.10"
PyGithub = "1.58.2"
kevinlu1248 marked this conversation as resolved.
Show resolved Hide resolved
PyGithub = "1.59.0"
loguru = "^0.6.0"
requests = "^2.28.2"
urllib3 = "<2.0.0"
Expand Down
18 changes: 18 additions & 0 deletions sweepai/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,24 @@ def __enter__(self):

@method()
def chunk(
self,
file_content: Union[str, List[str]],
Copy link
Member

Choose a reason for hiding this comment

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

Use | instead of Union and list instead of List

file_path: str,
score: float = 1.0,
additional_metadata: dict[str, str] = {},
max_chunk_size: int = 512 * 3,
chunk_size: int = 30,
overlap: int = 15
) -> tuple[list[str], list[dict[str, str]]]:
if isinstance(file_content, list):
results = []
for content in file_content:
result = self._chunk_single(content, file_path, score, additional_metadata, max_chunk_size, chunk_size, overlap)
results.append(result)
return results
else:
return self._chunk_single(file_content, file_path, score, additional_metadata, max_chunk_size, chunk_size, overlap)
def _chunk_single(
self,
file_content: str,
file_path: str,
Expand Down
Loading