Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: server: Pre-fill textarea and auto-generate based on query parameters #11150

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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

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, click(msg-send) on ?q
* main.js: once the App is mounted, focus(msg-input) on ?m
* examples/server/webui/index.html: assign id="msg-send" to the "Send" button

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]>
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.

1 participant