-
Notifications
You must be signed in to change notification settings - Fork 4
Add File System Support via pyodide.FS #37
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
fullzer4
wants to merge
32
commits into
langchain-ai:main
Choose a base branch
from
fullzer4:main
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 18 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
12009a0
feat(filesystem): add MEMFS filesystem support
fullzer4 d008190
Merge branch 'main' of github.com:fullzer4/langchain-sandbox into ful…
fullzer4 033c044
feat(sandbox): file attachment operations
fullzer4 c7d1896
fix: improve file system implementation and file handling
fullzer4 214ebf7
Merge pull request #1 from fullzer4/fullzer4/add_fyle_system
fullzer4 b5038cb
fix: conventions
fullzer4 3822ac9
Merge pull request #2 from fullzer4/fullzer4/add_fyle_system
fullzer4 bb115d3
fix: _build_command place convention
fullzer4 4262f83
Merge pull request #3 from fullzer4/fullzer4/add_fyle_system
fullzer4 f4584dc
fix: better filesystem operations and file handling
fullzer4 5b7b91d
feat: implement dynamic filesystem support with flexible tool archite…
fullzer4 bb23978
fix: follow python conventions
fullzer4 867b674
fix: typescript conventions
fullzer4 0bac09a
fix: rollback some tests
fullzer4 2511119
fix: permissions
fullzer4 6e9c104
feat: README changes
fullzer4 13f3057
fix: unified PyodideSandboxTool with complete backward compatibility
fullzer4 0d27435
fix: clean README
fullzer4 672eeb1
fix: lint
fullzer4 fd0285c
fix: Remove PyodideSandboxStructuredTool and fix unintentional README…
fullzer4 f03e6a0
fix: return file output limitation | remove local test functions
fullzer4 95e0f96
fixes
fullzer4 3d7317c
fixes
fullzer4 a042fd2
fix: improve filesystem operations and dynamic tool descriptions
fullzer4 ee4c4a2
Merge pull request #4 from fullzer4/fix/conventions-and-patterns
fullzer4 5cd6849
fix(pyodide): unrestrict file system access to ensure Pyodide can loa…
fullzer4 7665c23
fix: configure Deno permissions for reliable Pyodide execution
fullzer4 86f36c2
fix: restore uv.lock
fullzer4 db086a2
fix: restore uv.lock
fullzer4 d4267f7
fix: ensure custom descriptions are preserved in PyodideSandboxTool
fullzer4 37362fd
refactor: remove unnecessary filesystem operations (exists, remove, c…
fullzer4 5652d5c
revert: restore previous permission model and add allow_read to tests
fullzer4 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,48 @@ | ||
# pip install langgraph-codeact "langchain[anthropic]" | ||
import asyncio | ||
|
||
from langchain_sandbox import PyodideSandboxTool | ||
from langgraph.prebuilt import create_react_agent | ||
|
||
|
||
# Define the sandbox tool with filesystem support | ||
sandbox_tool = PyodideSandboxTool( | ||
enable_filesystem=True, | ||
allow_net=True, | ||
) | ||
|
||
sales_data = """date,product,category,quantity,price,region | ||
fullzer4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2024-01-15,Laptop,Electronics,2,1299.99,North | ||
2024-01-16,Chair,Furniture,1,249.50,South | ||
2024-01-16,T-shirt,Clothing,5,29.99,East | ||
2024-01-17,Laptop,Electronics,1,1299.99,West | ||
2024-01-18,Phone,Electronics,3,799.99,North | ||
2024-01-19,Desk,Furniture,2,399.99,South | ||
2024-01-20,Jeans,Clothing,4,79.99,East | ||
2024-01-21,Tablet,Electronics,2,499.99,West | ||
2024-01-22,Sofa,Furniture,1,899.99,North | ||
2024-01-23,Shoes,Clothing,3,129.99,South""" | ||
|
||
sandbox_tool.attach_file("sales.csv", sales_data) | ||
|
||
# Create an agent with the sandbox tool | ||
agent = create_react_agent( | ||
"anthropic:claude-3-7-sonnet-latest", [sandbox_tool] | ||
) | ||
|
||
query = """Please analyze the sales data and tell me: | ||
1. What is the total revenue by category? | ||
2. Which region has the highest sales? | ||
3. What are the top 3 best-selling products by revenue? | ||
|
||
Use pandas to read the CSV file and perform the analysis.""" | ||
|
||
async def run_agent(query: str): | ||
# Stream agent outputs | ||
async for chunk in agent.astream({"messages": query}): | ||
print(chunk) | ||
print("\n") | ||
|
||
if __name__ == "__main__": | ||
# Run the agent | ||
asyncio.run(run_agent(query)) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.