自定义 Slash Commands
自定义 slash command 是一种个性化快捷指令,用来快速运行 recipes。如果你有一个会生成日报的 recipe,就可以创建一个自定义 slash command,在会话里直接调用它:
/daily-report
创建 Slash Command
给某个 recipe 绑定一个自定义命令。
- goose Desktop
- goose CLI
- 点击左上角的 按钮打开侧边栏
- 点击侧边栏中的
Recipes - 找到你要使用的 recipe,点击 按钮
- 在弹出的窗口中输入自定义命令(不带前导
/) - 点击
Save
命令会显示在 Recipes 菜单里对应 recipe 的下方。如果该 recipe 不在你的 Recipe Library 中,请改用 goose CLI 的方式配置。
在你的配置文件中配置 slash command。把命令名(不带前导 /)和 recipe 文件在本机上的路径一起写进去:
~/.config/goose/config.yaml
slash_commands:
- command: "run-tests"
recipe_path: "/path/to/recipe.yaml"
- command: "daily-report"
recipe_path: "/Users/me/.local/share/goose/recipes/report.yaml"
使用 Slash Command
在任意聊天会话中,用带前导斜杠的方式输入自定义命令,并放在消息开头:
- goose Desktop
- goose CLI
/run-tests
可用命令提示
在 goose Desktop 中输入 /,会弹出一个菜单,展示当前可用的 slash commands。
Context: ●○○○○○○○○○ 5% (9695/200000 tokens)
( O)> /run-tests
如果有需要,你也可以在命令后额外传一个参数,引号可加可不加:
/translator where is the library
当你通过 slash command 运行一个 recipe 时,recipe 的 instructions 和 prompt 字段会被发送给模型,并加载进当前对话上下文,但不会直接显示在聊天记录里。模型会像你直接打开 recipe 一样,使用它的上下文和指令来回应。
限制
- Slash command 只能接收一个 parameter。如果 recipe 里定义了更多参数,其余参数必须有默认值。
- 命令名不区分大小写(
/Bug和/bug会被当作同一个命令)。 - 命令名必须唯一,且不能包含空格。
- 不能使用与内置 CLI slash commands 冲突的名称,例如
/recipe、/compact或/help。 - 如果 recipe 文件不存在或格式无效,这个命令会被当作普通文本发送给模型。