-
Notifications
You must be signed in to change notification settings - Fork 662
Add DeepReadFile tool for multi-format document support #10
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
ssgamingop
wants to merge
9
commits into
VRSEN:main
Choose a base branch
from
ssgamingop:feature/deep-read-file
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
9 commits
Select commit
Hold shift + click to select a range
df02123
Add DeepReadFile tool to the Deep Research Agent
ssgamingop 4503159
Add DeepReadFile tool for reading and converting files to Markdown
ssgamingop 205654d
Add DeepReadFile to shared_tools module exports
ssgamingop 440d548
Refactor import statements for better readability and organization
ssgamingop 13732a0
Enable Markdown to PDF/DOCX conversion in Docs Agent
ssgamingop 5fc4b12
Merge branch 'feature/markdown-conversion'
ssgamingop 405923a
Update dependencies to include markdown-it-py
ssgamingop 54c2f2f
Fix NameError in Deep Research Agent: import DeepReadFile
ssgamingop 0cef9d8
Fix Docs Agent bug: respect overwrite flag for both MD and HTML source
ssgamingop 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
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,55 @@ | ||
| import os | ||
| from typing import Optional | ||
| from agency_swarm.tools import BaseTool | ||
| from pydantic import Field | ||
| from markitdown import MarkItDown | ||
|
|
||
| class DeepReadFile(BaseTool): | ||
| """ | ||
| A tool to read and convert various file formats into Markdown. | ||
| Supports PDF, DOCX, XLSX, PPTX, HTML, and common image formats (via OCR if configured). | ||
|
|
||
| Use this tool when you need to understand the content of a non-plain-text file. | ||
| """ | ||
|
|
||
| file_path: str = Field(..., description="The absolute path to the file to read and convert.") | ||
|
|
||
| def run(self): | ||
| try: | ||
| # Ensure the path is absolute | ||
| abs_path = os.path.abspath(self.file_path) | ||
|
|
||
| if not os.path.exists(abs_path): | ||
| return f"Error: File does not exist at {abs_path}" | ||
|
|
||
| if not os.path.isfile(abs_path): | ||
| return f"Error: {abs_path} is not a file." | ||
|
|
||
| # Initialize MarkItDown | ||
| md = MarkItDown() | ||
|
|
||
| # Convert the file | ||
| result = md.convert(abs_path) | ||
|
|
||
| if not result or not result.text_content: | ||
| return f"Warning: Conversion successful but no text content was extracted from {os.path.basename(abs_path)}." | ||
|
|
||
| content = result.text_content | ||
|
|
||
| # Add a header to indicate the source | ||
| header = f"--- Content of {os.path.basename(abs_path)} ---\n\n" | ||
| return header + content | ||
|
|
||
| except Exception as e: | ||
| return f"Error converting file {self.file_path}: {str(e)}" | ||
|
|
||
| if __name__ == "__main__": | ||
| # Test with a simple text file first | ||
| test_file = "test_deep_read.txt" | ||
| with open(test_file, "w") as f: | ||
| f.write("# Test Heading\nThis is a test file for DeepReadFile.") | ||
|
|
||
| tool = DeepReadFile(file_path=os.path.abspath(test_file)) | ||
| print(tool.run()) | ||
|
|
||
| os.remove(test_file) |
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 |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| from shared_tools.CopyFile import CopyFile | ||
| from shared_tools.DeepReadFile import DeepReadFile | ||
| from shared_tools.ExecuteTool import ExecuteTool | ||
| from shared_tools.FindTools import FindTools | ||
| from shared_tools.ManageConnections import ManageConnections | ||
| from shared_tools.SearchTools import SearchTools | ||
|
|
||
| __all__ = ["CopyFile", "ExecuteTool", "FindTools", "ManageConnections", "SearchTools"] | ||
| __all__ = [ | ||
| "CopyFile", | ||
| "DeepReadFile", | ||
| "ExecuteTool", | ||
| "FindTools", | ||
| "ManageConnections", | ||
| "SearchTools", | ||
| ] |
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
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.
Uh oh!
There was an error while loading. Please reload this page.