]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
server : (webui) Enable communication with parent html (if webui is in iframe) (...
authorigardev <redacted>
Tue, 18 Feb 2025 22:01:44 +0000 (00:01 +0200)
committerGitHub <redacted>
Tue, 18 Feb 2025 22:01:44 +0000 (23:01 +0100)
commitb58934c1836b5ea51dbacbe899eee125775e77c9
treeb51b060abacefc96c6b4a7908fe57ea2c2c7da12
parent63e489c025d61c7ca5ec06c5d10f36e2b76aaa1d
server : (webui) Enable communication with parent html (if webui is in iframe) (#11940)

* Webui: Enable communication with parent html (if webui is in iframe):
- Listens for "setText" command from parent with "text" and "context" fields. "text" is set in inputMsg, "context" is used as hidden context on the following requests to the llama.cpp server
- On pressing na Escape button sends command "escapePressed" to the parent

Example handling from the parent html side:
- Send command "setText" from parent html to webui in iframe:
const iframe = document.getElementById('askAiIframe');
if (iframe) {
iframe.contentWindow.postMessage({ command: 'setText', text: text, context: context }, '*');
}

- Listen for Escape key from webui on parent html:
// Listen for escape key event in the iframe
window.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
// Process case when Escape is pressed inside webui
}
});

* Move the extraContext from storage to app.context.

* Fix formatting.

* add Message.extra

* format + build

* MessageExtraContext

* build

* fix display

* rm console.log

---------

Co-authored-by: igardev <redacted>
Co-authored-by: Xuan Son Nguyen <redacted>
examples/server/public/index.html.gz
examples/server/webui/src/components/ChatMessage.tsx
examples/server/webui/src/components/ChatScreen.tsx
examples/server/webui/src/utils/app.context.tsx
examples/server/webui/src/utils/llama-vscode.ts [new file with mode: 0644]
examples/server/webui/src/utils/misc.ts
examples/server/webui/src/utils/types.ts