Skip to content

Conversation

@tim-janik
Copy link

Description:

This PR proposes changes to the server Web UI to add the ability to pre-fill the textarea (id=msg-input) with a message supplied via a query parameter (?m=...) and auto-focus the textarea. Additionally, this allows pre-filling the textarea via a query parameter (?q=...) and automatically start generating a response.

Example Usage:

  1. Pre-fill the textarea and focus:

    http://localhost:8080/?m=Translate%20into%20Klingon%3A%20

  2. Pre-fill the textarea and automatically start generating a response:

    http://localhost:8080/?q=What%20is%20your%20name%3F

Proposed Changes:

  • Modify examples/server/webui/index.html to assign id=msg-input to the "Send" button.
  • Update examples/server/webui/src/main.js to:
    • Populate inputMsg from ?q or ?m.
    • Click the "Send" button on page load if ?q is present.
    • Focus the msg-input textarea on page load if ?m is present.

Use Cases:

By using browser bookmarks with query strings, several interesting model queries can be pre-populate, e.g.
?m=Summarize:, ?m=Translate%20to%20French:
And it allows quick testing and demonstrations: ?q=Howto%20build%20a%20Website

…button

Giving the button an id is needed to reliably call focus() after mounting.

Signed-off-by: Tim Janik <[email protected]>
Allow pre-filling the msg-input textarea with a message supplied via
a query parameter ?m=... and auto-focus the textarea. Example:
	http://localhost:8080/?m=What%20is%20your%20name?
Alternatively, allow pre-filling the msg-input textarea via a query
parameter ?q=... and automatically start generating a response, e.g.:
	http://localhost:8080/?q=What%20is%20your%20name?

* main.js: fill inputMsg from ?q or ?m
* main.js: once the App is mounted, call sendMessage() on ?q
* main.js: once the App is mounted, focus(msg-input) on ?m

Signed-off-by: Tim Janik <[email protected]>
Update via:
  cd ../llama.cpp/./examples/server/webui && npm i && npm run build

Signed-off-by: Tim Janik <[email protected]>
@ngxson
Copy link
Collaborator

ngxson commented Mar 2, 2025

Superseded by #12148

@ngxson ngxson closed this Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants