-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
270 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from e2b import Sandbox | ||
|
||
from e2b_code_interpreter import CodeInterpreter | ||
|
||
from astra_assistants.tools.tool_interface import ToolInterface | ||
|
||
|
||
class E2BCodeInterpreter(ToolInterface): | ||
|
||
def __init__(self): | ||
print("initializing code interpreter") | ||
|
||
running_sandboxes = Sandbox.list() | ||
# Find the sandbox by metadata | ||
for running_sandbox in running_sandboxes: | ||
if running_sandbox.metadata.get("user_id", "") == 'uniqueID': | ||
sandbox = Sandbox.reconnect(running_sandbox.sandbox_id) | ||
sandbox.close() | ||
else: | ||
# Sandbox not found | ||
pass | ||
self.code_interpreter = CodeInterpreter() | ||
|
||
print("initialized") | ||
|
||
def call(self, arguments): | ||
code = arguments['arguments'] | ||
exec = self.code_interpreter.notebook.exec_cell( | ||
code, | ||
) | ||
return exec.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.