跳转到主要内容

由OpenAI和Docker驱动的任务运行器。

项目描述

botsh

PyPI version

botsh 将聊天代理附加到运行Ubuntu的Docker容器。

这实际上让代理能够访问整个 APT 宇宙,同时将其影响范围限制在当前目录(该目录被挂载到容器中)。

演示

此演示使用提示 创建一个包含不同数字的100个200x200图像序列,并用ffmpeg将它们转换为30fps视频

botsh:

  • 尝试运行 imagemagick 并失败(因为它是一个全新的Ubuntu安装)
  • 安装 imagemagick
  • 尝试运行 ffmpeg 并失败
  • 安装 ffmpeg
  • 尝试将帧转换为视频并失败(因为它尚未创建它们)
  • 使用 imagemagick 编写一个bash循环来生成100帧
  • 使用 ffmpeg 将它们转换为视频

https://user-images.githubusercontent.com/46173/230953506-c8545345-c0a1-46b1-b937-458191fc2456.mp4

设置

使用以下方式安装

pip install botsh

botsh 预期将OpenAI API密钥作为 OPENAI_API_KEY 环境变量提供。

botsh 还需要系统上运行Docker。

示例

botsh "convert cat.jpg into a png file"

botsh "use a remote service to find my public ip and base64 encode it"

botsh "run pylint on the codebase in src/"

其他详情

botsh 将创建与当前目录关联的裸Ubuntu Docker容器,如果不存在则创建一个。然后,botsh 将将OpenAI API附加到容器中运行的shell,以尝试完成给定的任务。

人工智能被明确告知可以安装软件,通常会在完成任务时按需安装程序。已安装的软件将保持在容器内。

观察

以下观察与默认模型 text-davinci-003 相关。使用 GPT-4 可能会改善情况。

  • 如果明确指定要处理的文件/路径(使用相对引用),则效果最佳。它不擅长理解你的意图。
  • 如果无法完成任务,它通常会陷入循环,而不是放弃,尽管提示中告诉它不要这样做。
  • 有时需要微妙的鼓励将其分解成多个部分,而不是将一个长shell命令连接起来,尤其是在它想要运行的命令有错误时。例如,与其说“将 foo.png 转换为 gif 并计算其 md5 哈希”,不如说“将 foo.png 转换为 gif,然后计算其 md5 哈希”

容器重用

当调用 botsh 时,当前工作目录会被挂载到容器中,并由代理运行的程序进行修改。当前工作目录之外的文件系统与容器隔离开来。

你每次在目录中运行 botsh,都会为其创建一个容器,该容器将用于该容器中未来对 botsh 的调用。

在运行任务之前,你可以使用 --wipe 来丢弃现有容器并启动一个新的容器。你还可以在任务结束时使用 --rm 来删除容器。

如果你使用 docker container prune 在 Docker 中清除容器,容器也将被删除。

用法

usage: botsh [-h] [--max-rounds MAX_ROUNDS] [--model MODEL] [--image IMAGE] [--shell-command SHELL_COMMAND] [--save-transcript] [--wipe] prompt

Task runner powered by OpenAI and Docker. Invoke botsh by providing a task as a command line argument. botsh will create a bare Ubuntu Docker container associated with the current directory, or create one if one does not exist. botsh will then attach the OpenAI API to a shell running in the container to attempt to complete the given task.

positional arguments:
  prompt                Prompt to execute.

options:
  -h, --help            show this help message and exit
  --max-rounds MAX_ROUNDS
  --model MODEL         OpenAI text completion model to use.
  --image IMAGE         Docker image to use.The current hard-coded prompt works for Debian-derived distributions.
  --shell-command SHELL_COMMAND
                        Shell to invoke within the container.
  --save-transcript     Save transcript to file
  --wipe                Start with a fresh container even if one exists for this directory.

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解有关 安装包 的更多信息。

源分布

botsh-0.1.7.tar.gz (40.1 kB 查看哈希值)

上传时间

由以下机构支持