-
Notifications
You must be signed in to change notification settings - Fork 86
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
Code graph pipeline improvements and fixes #414
Changes from 10 commits
a8a83ff
399faf9
a6dfff8
4cee9a1
dbc33a6
5e79dc5
4802567
fbf8fc9
a774191
fb13a1b
0dec704
8ffef50
f4397bf
34a9267
97814e3
d1d81eb
2e37f85
5635da6
6762039
abb3ea6
cdaae16
626bc76
d7b2186
18bb282
7e10349
a11b914
5839ab0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,4 @@ | ||||||||||||||||||
from typing import Optional | ||||||||||||||||||
from uuid import UUID | ||||||||||||||||||
|
||||||||||||||||||
from cognee.infrastructure.engine import DataPoint | ||||||||||||||||||
|
@@ -13,5 +14,5 @@ class Document(DataPoint): | |||||||||||||||||
"type": "Document" | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
def read(self, chunk_size: int, chunker = str) -> str: | ||||||||||||||||||
def read(self, chunk_size: int, embedding_model: Optional[str], max_tokens: Optional[int], chunker = str) -> str: | ||||||||||||||||||
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. Update default values for new parameters in The new parameters Apply this diff to set default values: def read(
self,
chunk_size: int,
- embedding_model: Optional[str],
- max_tokens: Optional[int],
+ embedding_model: Optional[str] = None,
+ max_tokens: Optional[int] = None,
chunker=str,
) -> str:
pass 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: ruff format[error] 308 files require formatting according to Ruff standards. Run Ruff formatter to fix formatting issues. 💡 Codebase verification Update missing read methods in ImageDocument and AudioDocument The following classes need to implement the read method with the updated signature
🔗 Analysis chainEnsure all subclasses override the updated The The pipeline failure indicates that Run the following script to identify classes that need updating: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Find all subclasses of Document that need to update the `read` method.
# Find files containing classes that inherit from Document but do not have updated `read` methods
fd --type f --extension py '.*' | xargs grep -l 'class .*Document(Document):' | xargs grep -L 'def read(self, chunk_size'
# Alternatively, use ast-grep to find method definitions
ast-grep --pattern 'class $CLASS_NAME(Document): {$$$ def read(self, chunk_size: int, $$$): $$$ }' --ignore 'test_*'
Length of output: 490 Script: #!/bin/bash
# Find Document subclasses
echo "=== Document subclasses ==="
ast-grep --pattern 'class $NAME(Document)'
echo -e "\n=== Read method implementations ==="
# Find read method implementations
ast-grep --pattern 'def read(self, $$$)'
echo -e "\n=== Backup search with ripgrep ==="
# Backup search with ripgrep
rg "class.*\(Document\)" -A 5
Length of output: 3351 🧰 Tools🪛 GitHub Actions: ruff format[error] 308 files require formatting according to Ruff standards. Run Ruff formatter to fix formatting issues. |
||||||||||||||||||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
from typing import Optional | ||
|
||
from cognee.modules.data.processing.document_types.Document import Document | ||
|
||
|
||
async def extract_chunks_from_documents(documents: list[Document], chunk_size: int = 1024, chunker = 'text_chunker'): | ||
async def extract_chunks_from_documents( | ||
documents: list[Document], | ||
chunk_size: int = 1024, | ||
chunker='text_chunker', | ||
embedding_model: Optional[str] = None, | ||
max_tokens: Optional[int] = None, | ||
): | ||
for document in documents: | ||
for document_chunk in document.read(chunk_size = chunk_size, chunker = chunker): | ||
for document_chunk in document.read(chunk_size=chunk_size, chunker=chunker, embedding_model=embedding_model, max_tokens=max_tokens): | ||
alekszievr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
yield document_chunk |
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.
As the embedding_engine shouldn't change in code and should only be changed through environment configuration I think we should remove it as a parameter to functions and instead get it dynamically with the getter when needed