Skip to content

Commit

Permalink
clean up of v
Browse files Browse the repository at this point in the history
Former-commit-id: a6b8773
  • Loading branch information
Kye committed Aug 3, 2023
1 parent e039eeb commit dccfe61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions DOCS/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ The `temperature`, `top_p`, `top_k`, and `n` parameters control the randomness a



## `CodeInterpreterTool`:
## `CodeInterpreter`:

```python
tool = CodeInterpreterTool("Code Interpreter", "A tool to interpret code and generate useful outputs.")
tool = CodeInterpreter("Code Interpreter", "A tool to interpret code and generate useful outputs.")
tool.run("Plot the bitcoin chart of 2023 YTD")

# Or with file inputs
Expand All @@ -358,11 +358,11 @@ To use the asynchronous version, simply replace `run` with `arun` and ensure you
```python
import asyncio

tool = CodeInterpreterTool("Code Interpreter", "A tool to interpret code and generate useful outputs.")
tool = CodeInterpreter("Code Interpreter", "A tool to interpret code and generate useful outputs.")
asyncio.run(tool.arun("Plot the bitcoin chart of 2023 YTD"))

# Or with file inputs
asyncio.run(tool.arun("Analyze this dataset and plot something interesting about it.", ["examples/assets/iris.csv"]))
```

The `CodeInterpreterTool` class is a flexible tool that uses the `CodeInterpreterSession` from the `codeinterpreterapi` package to run the code interpretation and return the result. It provides both synchronous and asynchronous methods for convenience, and ensures that exceptions are handled gracefully.
The `CodeInterpreter` class is a flexible tool that uses the `CodeInterpreterSession` from the `codeinterpreterapi` package to run the code interpretation and return the result. It provides both synchronous and asynchronous methods for convenience, and ensures that exceptions are handled gracefully.
10 changes: 5 additions & 5 deletions swarms/agents/tools/code_intepretor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Callable, Any, List
from codeinterpreterapi import CodeInterpreterSession, File, ToolException

class CodeInterpreterTool(Tool):
class CodeInterpreter(Tool):
def __init__(self, name: str, description: str):
super().__init__(name, description, self.run)

Expand All @@ -24,7 +24,7 @@ def run(self, user_request: str, file_paths: List[str] = []) -> Any:
for file in response.files:
file.show_image()
except Exception as e:
raise ToolException(f"Error running CodeInterpreterTool: {e}")
raise ToolException(f"Error running CodeInterpreter: {e}")
finally:
# terminate the session
session.stop()
Expand All @@ -46,14 +46,14 @@ async def arun(self, user_request: str, file_paths: List[str] = []) -> Any:
for file in response.files:
file.show_image()
except Exception as e:
raise ToolException(f"Error running CodeInterpreterTool: {e}")
raise ToolException(f"Error running CodeInterpreter: {e}")
finally:
# terminate the session
await session.astop()

"""
tool = CodeInterpreterTool("Code Interpreter", "A tool to interpret code and generate useful outputs.")
tool = CodeInterpreter("Code Interpreter", "A tool to interpret code and generate useful outputs.")
tool.run("Plot the bitcoin chart of 2023 YTD")
# Or with file inputs
Expand All @@ -63,7 +63,7 @@ async def arun(self, user_request: str, file_paths: List[str] = []) -> Any:
import asyncio
tool = CodeInterpreterTool("Code Interpreter", "A tool to interpret code and generate useful outputs.")
tool = CodeInterpreter("Code Interpreter", "A tool to interpret code and generate useful outputs.")
asyncio.run(tool.arun("Plot the bitcoin chart of 2023 YTD"))
# Or with file inputs
Expand Down

0 comments on commit dccfe61

Please sign in to comment.