From dccfe61e34291c47990d8931d621abc70b59a0aa Mon Sep 17 00:00:00 2001 From: Kye Date: Thu, 3 Aug 2023 14:24:23 -0400 Subject: [PATCH] clean up of v Former-commit-id: a6b8773c59ce6153f3bdf1b588a72a3bf8bad19e --- DOCS/DOCUMENTATION.md | 8 ++++---- swarms/agents/tools/code_intepretor.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/DOCS/DOCUMENTATION.md b/DOCS/DOCUMENTATION.md index a77c0d6d4..b9c33b51f 100644 --- a/DOCS/DOCUMENTATION.md +++ b/DOCS/DOCUMENTATION.md @@ -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 @@ -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/swarms/agents/tools/code_intepretor.py b/swarms/agents/tools/code_intepretor.py index a832dd3e5..679fca8ef 100644 --- a/swarms/agents/tools/code_intepretor.py +++ b/swarms/agents/tools/code_intepretor.py @@ -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) @@ -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() @@ -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 @@ -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