Skip to content

Commit

Permalink
remove changes in other files
Browse files Browse the repository at this point in the history
  • Loading branch information
zyzhang1130 committed Oct 24, 2024
1 parent 59dd55f commit 56fa035
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
28 changes: 26 additions & 2 deletions examples/data_interpreter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ These models are tested in this example. For other models, some modifications ma

To run this example, you need:

- **Python 3.x**

- **Agentscope** package installed:

```bash
Expand Down Expand Up @@ -64,6 +62,32 @@ To run this example, you need:

This step enables the executed code by the agents to perform required operations that are otherwise restricted by default. Ensure you understand the security implications of modifying these restrictions.

- Comment out the following in `src/agentscope/utils/common.py`:
```python
@contextlib.contextmanager
def create_tempdir() -> Generator:
"""
A context manager that creates a temporary directory and changes the
current working directory to it.
The implementation of this contextmanager are borrowed from
https://github.com/openai/human-eval/blob/master/human_eval/execution.py
"""
with tempfile.TemporaryDirectory() as dirname:
with _chdir(dirname):
yield dirname
```

and add
```python
@contextlib.contextmanager
def create_tempdir() -> Generator:
"""
A context manager that uses the curreny directory.
"""
yield
```
to use the current directory for code execution.

- **Optional Packages** (if needed for specific tools or extended functionalities):

- `litellm` for interacting with the Claude model.
Expand Down
25 changes: 8 additions & 17 deletions src/agentscope/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import socket
import string
import sys

# import tempfile
import tempfile
import threading
from typing import Any, Generator, Optional, Union, Tuple, Literal, List
from urllib.parse import urlparse
Expand Down Expand Up @@ -58,25 +57,17 @@ def signal_handler(*args: Any, **kwargs: Any) -> None:
signal.setitimer(signal.ITIMER_REAL, 0)


# @contextlib.contextmanager
# def create_tempdir() -> Generator:
# """
# A context manager that creates a temporary directory and changes the
# current working directory to it.
# The implementation of this contextmanager are borrowed from
# https://github.com/openai/human-eval/blob/master/human_eval/execution.py
# """
# with tempfile.TemporaryDirectory() as dirname:
# with _chdir(dirname):
# yield dirname


@contextlib.contextmanager
def create_tempdir() -> Generator:
"""
A context manager that uses the curreny directory.
A context manager that creates a temporary directory and changes the
current working directory to it.
The implementation of this contextmanager are borrowed from
https://github.com/openai/human-eval/blob/master/human_eval/execution.py
"""
yield
with tempfile.TemporaryDirectory() as dirname:
with _chdir(dirname):
yield dirname


@contextlib.contextmanager
Expand Down

0 comments on commit 56fa035

Please sign in to comment.