llama.cpp/examples/server/webui/src/utils
igardev b58934c183
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 <ivailo.gardev@akros.ch>
Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
2025-02-18 23:01:44 +01:00
..
app.context.tsx server : (webui) Enable communication with parent html (if webui is in iframe) (#11940) 2025-02-18 23:01:44 +01:00
common.tsx server : (webui) revamp Settings dialog, add Pyodide interpreter (#11759) 2025-02-08 21:54:50 +01:00
llama-vscode.ts server : (webui) Enable communication with parent html (if webui is in iframe) (#11940) 2025-02-18 23:01:44 +01:00
misc.ts server : (webui) Enable communication with parent html (if webui is in iframe) (#11940) 2025-02-18 23:01:44 +01:00
storage.ts server : (webui) introduce conversation branching + idb storage (#11792) 2025-02-10 21:23:17 +01:00
types.ts server : (webui) Enable communication with parent html (if webui is in iframe) (#11940) 2025-02-18 23:01:44 +01:00