-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
base: master
Are you sure you want to change the base?
Conversation
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]>
@@ -153,7 +153,7 @@ <h2 class="font-bold ml-4">Conversations</h2> | |||
:disabled="isGenerating" | |||
id="msg-input" | |||
></textarea> | |||
<button v-if="!isGenerating" class="btn btn-primary ml-2" @click="sendMessage" :disabled="inputMsg.length === 0">Send</button> | |||
<button v-if="!isGenerating" class="btn btn-primary ml-2" @click="sendMessage" :disabled="inputMsg.length === 0" id="msg-send">Send</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This button calls sendMessage()
function as stated in @click
. You should call the underlay function instead of assigning an ID for it.
@@ -1,5 +1,6 @@ | |||
import './styles.scss'; | |||
import { createApp, defineComponent, shallowRef, computed, h } from 'vue/dist/vue.esm-bundler.js'; | |||
import { nextTick } from 'vue/dist/vue.esm-bundler.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we add this to the line above it?
@@ -313,6 +314,9 @@ async function* sendSSEPostRequest(url, fetchOptions) { | |||
} | |||
}; | |||
|
|||
const usp = new URLSearchParams (window.location.search); | |||
const initial_query = usp.get ('q'), initial_msg = initial_query || usp.get ('m') || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pay attention to the coding style too
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:
Pre-fill the textarea and focus:
http://localhost:8080/?m=Translate%20into%20Klingon%3A%20
Pre-fill the textarea and automatically start generating a response:
http://localhost:8080/?q=What%20is%20your%20name%3F
Proposed Changes:
examples/server/webui/index.html
to assignid=msg-input
to the "Send" button.examples/server/webui/src/main.js
to:inputMsg
from?q
or?m
.?q
is present.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