专栏名称: GitHubStore
分享有意思的开源项目
目录
相关文章推荐
什么值得买  ·  这个节电小玩意,骗了多少农村老人?? ·  2 天前  
上海市场监管  ·  明天开始!新一轮消费券就按攻略这么领→ ·  3 天前  
上海市场监管  ·  明天开始!新一轮消费券就按攻略这么领→ ·  3 天前  
华人生活网  ·  手速要快!巴塔、Burberry、CK、汤米 ... ·  3 天前  
华人生活网  ·  手速要快!巴塔、Burberry、CK、汤米 ... ·  3 天前  
51好读  ›  专栏  ›  GitHubStore

E2B桌面沙箱:为大型语言模型提供图形桌面环境的沙盒服务

GitHubStore  · 公众号  ·  · 2024-11-05 09:16

正文

项目简介

E2B 桌面沙箱是一个隔离的云环境,具有由E2B提供支持的类似桌面的界面。可供计算机使用。


启动 E2B Sandbox 大约需要 300-500 毫秒。您可以使用我们的自定义沙箱模板自定义桌面环境并预安装所需的任何依赖项。


正在进行的工作 该存储库是一项正在进行的工作。我们欢迎反馈和贡献。以下是我们正在开发的功能列表:

  • JavaScript SDK

  • 流媒体直播桌面

  • 测试

  • 文档字符串


入门

E2B 桌面沙箱构建于E2B 沙箱之上。

1. Get E2B API key
1. 获取E2B API密钥

在E2B注册并获取您的 API 密钥。使用您的 API 密钥设置环境变量 E2B_API_KEY


2.安装SDK

Python

pip install e2b-desktop

JavaScript

Coming soon


3. 创建桌面沙箱

from e2b_desktop import Sandbox
desktop = Sandbox()

特征

鼠标控制

from e2b_desktop import Sandboxdesktop = Sandbox()
desktop.double_click()desktop.left_click()desktop.right_click()desktop.middle_click()desktop.scroll(10) # Scroll by the amount. Positive for up, negative for down.desktop.mouse_move(100, 200) # Move to x, y coordinates

在屏幕上找到

from e2b_desktop import Sandboxdesktop = Sandbox()
# Find "Home" text on the screen and return the coordinatesx, y = desktop.locate_on_screen("Home")# Move the mouse to the coordinatesdesktop.mouse_move(x, y)

键盘控制

from e2b_desktop import Sandboxdesktop = Sandbox()
desktop.write("Hello, world!") # Write text at the current cursor positiondesktop.hotkey("ctrl", "c") # Press ctrl+c

截屏

from e2b_desktop import Sandboxdesktop = Sandbox()
# Take a screenshot and save it as "screenshot.png" locallydesktop.screenshot("screenshot.png")

打开文件

from e2b_desktop import Sandboxdesktop = Sandbox()
# Open file with default applicationdesktop.files.write("/home/user/index.js", "console.log('hello')") # First create the filedesktop.open("/home/user/index.js") # Then open it

运行任何 bash 命令

from e2b_desktop import Sandboxdesktop = Sandbox()
# Run any bash commanddesktop.commands.run("ls -la /home/user")

运行 PyAutoGUI 命令

from e2b_desktop import Sandboxdesktop = Sandbox()
# Run any PyAutoGUI commanddesktop.pyautogui("pyautogui.click()"






请到「今天看啥」查看全文