huggingface / huggingface/chat-ui

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

Open
#611 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
11k
Forks
1.7k
Avg merge
21h 24m
Merged PRs (30d)
56

Description

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:**

```json
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:**

```json
{
"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`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the related issues #464 and #462 and deciding whether the scope includes text commands, handlebars templates, autocompletion, and external API requests. Done should be an agreed command format, behavior for the examples in this issue, and tests covering the selected scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
handlebars
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.