Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
Former-commit-id: 493b061
  • Loading branch information
Kye committed Aug 3, 2023
1 parent d6f37ae commit e039eeb
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions DOCS/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,61 +343,6 @@ The `temperature`, `top_p`, `top_k`, and `n` parameters control the randomness a



Here's a `CodeInterpreterTool` class adhering to your abstract `Tool` class:

```python
from typing import Callable, Any, List
from codeinterpreterapi import CodeInterpreterSession, File, ToolException

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

def run(self, user_request: str, file_paths: List[str] = []) -> Any:
# create a session
session = CodeInterpreterSession()
session.start()

# create files from paths
files = [File.from_path(file_path) for file_path in file_paths]

try:
# generate a response based on user input
response = session.generate_response(user_request, files=files)

# output the response (text + image)
print("AI: ", response.content)
for file in response.files:
file.show_image()
except Exception as e:
raise ToolException(f"Error running CodeInterpreterTool: {e}")
finally:
# terminate the session
session.stop()

async def arun(self, user_request: str, file_paths: List[str] = []) -> Any:
# create a session
session = CodeInterpreterSession()
await session.astart()

# create files from paths
files = [File.from_path(file_path) for file_path in file_paths]

try:
# generate a response based on user input
response = await session.generate_response(user_request, files=files)

# output the response (text + image)
print("AI: ", response.content)
for file in response.files:
file.show_image()
except Exception as e:
raise ToolException(f"Error running CodeInterpreterTool: {e}")
finally:
# terminate the session
await session.astop()
```

## `CodeInterpreterTool`:

```python
Expand Down

0 comments on commit e039eeb

Please sign in to comment.