Add 4 files
Browse filesFiles changed (4)
- app.jsAdded+33
- index.html+1-19
- main.jsAdded+17
- safeteans-llm.jsAdded+27
123456789101112131415161718192021222324252627282930313233import SafeteansLLM from './safeteans-llm';
class App { constructor({ el, data, methods, created }) { // Create the LLM instance this.llm = new SafeteansLLM();
// Mount the root component this.render([{ el: el, data: data, methods: methods, created: created, }]); }
render({ el, data, methods, created }) { // Create the element const element = createElement(el);
// Set the data and methods Object.keys(data).forEach(key => element.dataset[key] = data[key]); Object.keys(methods).forEach(key => element[key] = methods[key]);
// Set the created callback if (created) created(element);
// Append the element to the body document.body.appendChild(element); }}
export default App;12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>1<html><head><link href="https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>Safeteans Chat Interface</title></head><body style="height: 100vh; display: flex; flex-direction: column;"><div style="flex: 1; display: flex; flex-direction: column; align-items: center;"><h1 style="margin-top: -40em; margin-bottom: 0em; color: yellow;">Safeteans Chat Interface</h1><div style="margin-top: 2em; overflow: auto; height: 100%;"><div id="app" class="p-8"><div class="max-w-lg mx-auto prose"><h3 class="text-xl">Please enter your message:</h3><textarea class="w-full" rows="4" cols="50" id="message" placeholder="Type your message here..."></textarea></div></div></div></div></body></html>
1234567891011121314151617import 'https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js';import * as from './app.js';
const app = new App({ el: '#app', data: { message: '', }, methods: { handleInput: function(event) { this.message = event.target.value; }, }, created: function() { this.message = 'Initialize your message...'; },});123456789101112131415161718192021222324252627class SafeteansLLM { constructor() { // Create the WebSocket connection this.socket = new WebSocket('wss://<server-url>');
// Listen for incoming messages this.socket.onmessage = this.handleMessage; }
handleMessage(event) { // Parse the incoming message const message = JSON.parse(event.data);
// Print the message to the console console.log(message); }
sendMessage(message) { // Stringify the message const data = JSON.stringify(message);
// Send the message over the WebSocket this.socket.send(data); }}
export default SafeteansLLM;app.jsAdded+33
index.html+1-19
main.jsAdded+17
safeteans-llm.jsAdded+27