Skip to content

[Feature Request] Chat: Custom /commands expanding to prompts #611

Open
@secondtruth

Description

@secondtruth

Inspired by #464, I'd like to suggest custom slash-commands defined in the env (on model level and/or global level), that will be expanded to prompt text, maybe using handlebars templates. This could also be useful in the future for inserting user-defined prompts by a shortname or calling agents (#462), made even easier with some kind of autocompletion.

Suggestions and improvements of this proposal are very welcome!

Example:

CHAT_COMMANDS=`[
  {
    "command": "news",
    "description": "Get a summary of the latest news.",
    "type": "text",
    "content": "Please summarize today's news.",
    "features": {
      "websearch": true // temporarily enable websearch feature
    }
  }, {
    "command": "words-starting-with",
    "description": "Get words starting with your favorite letter.",
    "min_args": 1,
    "type": "template",
    "content": "Find {{#if args[1]}}{{args[1]}}{{else}}5{{/if}} words starting with {{args[0]}}"
  }
]`
  • Usage example for Command 1: /news
  • Usage example for Command 2: /words-starting-with a

Additional Proposal: Prompts from external APIs

In building upon the previous feature concept, a future enhancement is proposed to allow commands to trigger API requests, thereby enabling completely dynamic prompt generation based on external data or services. This would significantly increase the versatility and interactivity of the commands.

Example:

  {
    "command": "do-request",
    "description": "Do an API request that returns a prompt text.",
    "min_args": 2,
    "type": "request",
    "request": {
      "url": "https://example.com/script",
      "method": "post",
      "datatype": "json",
      "data": {
        "x": "{{args[0]}}",
        "y": "{{args[1]}}"
      },
      "result": {
        "datatype": "json",
        "path": "result.prompt_text",
        "templated": true
      }
    }
  }
  • Usage example for Command: /do-request 1, 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions