llama.cpp/examples/server/webui
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
..
public server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
src server : (webui) Enable communication with parent html (if webui is in iframe) (#11940) 2025-02-18 23:01:44 +01:00
.gitignore server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
.prettierignore server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
eslint.config.js server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
index.html server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
package-lock.json server : (webui) introduce conversation branching + idb storage (#11792) 2025-02-10 21:23:17 +01:00
package.json server : (webui) introduce conversation branching + idb storage (#11792) 2025-02-10 21:23:17 +01:00
postcss.config.js server : (web ui) Various improvements, now use vite as bundler (#10599) 2024-12-03 19:38:44 +01:00
tailwind.config.js server : (web ui) Various improvements, now use vite as bundler (#10599) 2024-12-03 19:38:44 +01:00
tsconfig.app.json server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
tsconfig.json server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
tsconfig.node.json server : (webui) migrate project to ReactJS with typescript (#11688) 2025-02-06 17:32:29 +01:00
vite.config.ts server : (webui) revamp Settings dialog, add Pyodide interpreter (#11759) 2025-02-08 21:54:50 +01:00