Make e2b optional dependency (#292)
* Make e2b optional dependency with extra * Make e2b imports optional * Update e2b docs
This commit is contained in:
parent
257c1fe33b
commit
16f7910df8
|
@ -60,7 +60,7 @@ For maximum security, you can use our integration with E2B to run code in a sand
|
|||
|
||||
For this, you will need to setup your E2B account and set your `E2B_API_KEY` in your environment variables. Head to [E2B's quickstart documentation](https://e2b.dev/docs/quickstart) for more information.
|
||||
|
||||
Then you can install it with `pip install e2b-code-interpreter python-dotenv`.
|
||||
Then you can install it with `pip install "smolagents[e2b]"`.
|
||||
|
||||
Now you're set!
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ dependencies = [
|
|||
"pillow>=11.0.0",
|
||||
"markdownify>=0.14.1",
|
||||
"duckduckgo-search>=6.3.7",
|
||||
"python-dotenv>=1.0.1",
|
||||
"e2b-code-interpreter>=1.0.3",
|
||||
"torchvision"
|
||||
]
|
||||
|
||||
|
@ -38,6 +36,10 @@ transformers = [
|
|||
"transformers>=4.0.0",
|
||||
"smolagents[torch]",
|
||||
]
|
||||
e2b = [
|
||||
"e2b-code-interpreter>=1.0.3",
|
||||
"python-dotenv>=1.0.1",
|
||||
]
|
||||
gradio = [
|
||||
"gradio>=5.8.0",
|
||||
]
|
||||
|
@ -55,10 +57,11 @@ quality = [
|
|||
"ruff>=0.9.0",
|
||||
]
|
||||
all = [
|
||||
"smolagents[accelerate,audio,gradio,litellm,mcp,openai,transformers]",
|
||||
"smolagents[accelerate,audio,e2b,gradio,litellm,mcp,openai,transformers]",
|
||||
]
|
||||
test = [
|
||||
"pytest>=8.1.0",
|
||||
"python-dotenv>=1.0.1", # For test_all_docs
|
||||
"smolagents[all]",
|
||||
]
|
||||
dev = [
|
||||
|
|
|
@ -20,8 +20,6 @@ import textwrap
|
|||
from io import BytesIO
|
||||
from typing import Any, List, Tuple
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from e2b_code_interpreter import Sandbox
|
||||
from PIL import Image
|
||||
|
||||
from .tool_validation import validate_tool_attributes
|
||||
|
@ -29,11 +27,23 @@ from .tools import Tool
|
|||
from .utils import BASE_BUILTIN_MODULES, instance_to_source
|
||||
|
||||
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
class E2BExecutor:
|
||||
def __init__(self, additional_imports: List[str], tools: List[Tool], logger):
|
||||
try:
|
||||
from e2b_code_interpreter import Sandbox
|
||||
except ModuleNotFoundError:
|
||||
raise ModuleNotFoundError(
|
||||
"""Please install 'e2b' extra to use E2BExecutor: `pip install "smolagents[e2b]"`"""
|
||||
)
|
||||
|
||||
self.custom_tools = {}
|
||||
self.sbx = Sandbox() # "qywp2ctmu2q7jzprcf4j")
|
||||
# TODO: validate installing agents package or not
|
||||
|
|
Loading…
Reference in New Issue