mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Merge pull request #148 from HammamWahab/main
Enabled connection to docker daemon with manual setting of docker base url for code interpreter tool. (Issue #1555)
This commit is contained in:
@@ -38,3 +38,16 @@ Agent(
|
|||||||
tools=[CodeInterpreterTool(user_dockerfile_path="<Dockerfile_path>")],
|
tools=[CodeInterpreterTool(user_dockerfile_path="<Dockerfile_path>")],
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If it is difficult to connect to docker daemon automatically (especially for macOS users), you can do this to setup docker host manually
|
||||||
|
|
||||||
|
```python
|
||||||
|
from crewai_tools import CodeInterpreterTool
|
||||||
|
|
||||||
|
Agent(
|
||||||
|
...
|
||||||
|
tools=[CodeInterpreterTool(user_docker_base_url="<Docker Host Base Url>",
|
||||||
|
user_dockerfile_path="<Dockerfile_path>")],
|
||||||
|
)
|
||||||
|
|
||||||
|
```
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class CodeInterpreterTool(BaseTool):
|
|||||||
default_image_tag: str = "code-interpreter:latest"
|
default_image_tag: str = "code-interpreter:latest"
|
||||||
code: Optional[str] = None
|
code: Optional[str] = None
|
||||||
user_dockerfile_path: Optional[str] = None
|
user_dockerfile_path: Optional[str] = None
|
||||||
|
user_docker_base_url: Optional[str] = None
|
||||||
unsafe_mode: bool = False
|
unsafe_mode: bool = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -41,7 +42,8 @@ class CodeInterpreterTool(BaseTool):
|
|||||||
"""
|
"""
|
||||||
Verify if the Docker image is available. Optionally use a user-provided Dockerfile.
|
Verify if the Docker image is available. Optionally use a user-provided Dockerfile.
|
||||||
"""
|
"""
|
||||||
client = docker_from_env()
|
|
||||||
|
client = docker_from_env() if self.user_docker_base_url == None else docker.DockerClient(base_url=self.user_docker_base_url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client.images.get(self.default_image_tag)
|
client.images.get(self.default_image_tag)
|
||||||
|
|||||||
Reference in New Issue
Block a user