[BUG] CodeExecutionToolkit使用e2b执行代码的时候, 如果代码的功能是生成文件而不是直接打印结果,会获取不到结果
Required prerequisites
- [x] I have read the documentation https://camel-ai.github.io/camel/camel.html.
- [x] I have searched the Issue Tracker and Discussions that this hasn't already been reported. (+1 or comment there if it has.)
- [x] Consider asking first in a Discussion.
What version of camel are you using?
0.2.34
System information
print(sys.version, sys.platform) 3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)] win32 print(camel.version) 0.2.34
Problem description
CodeExecutionToolkit在e2b执行代码的时候,例如matplotlib画图之类的代码,输出不是文本类型,会拿不到执行结果
Reproducible example code
The Python snippets:
E2BInterpreter.run(f)
Command lines:
Extra dependencies:
Steps to reproduce:
Traceback
Expected behavior
No response
Additional context
No response
files = sbx.files.list("/home/user") #e2b默认文件保存路径 print(files) common_files = [entry for entry in files if is_common_file_format(entry.name)]
save_path = r""
for file in common_files: # Write file to local filesystem mime_type, _ = mimetypes.guess_type(file.name)
# 判断MIME类型是否为None
if mime_type is None:
# 如果无法判断MIME类型,则使用二进制写入模式
mode = 'wb'
else:
# 根据MIME类型判断是否为文本文件
if 'text' in mime_type:
mode = 'w'
encoding = 'utf-8'
else:
mode = 'wb'
encoding = None
with open(os.path.join(save_path, file.name), mode, encoding=encoding) as f:
f_format = "text" if encoding else "bytes"
content = sbx.files.read(file.path, format=f_format)
f.write(content)
如果是生成文件类型的代码,大概可以通过这种方式拿到e2b的sandbox里的文件。但我不清楚如果我拿到了文件之后, 要怎么return数据才能让任务继续执行
do you mind translating the issue please?
Hey do you mind illustrate or show how you tested the CodeExecutionToolKit using e2b with such as the example of matplotlib mentioned above?