Spaces:
Running
Running
File size: 1,129 Bytes
476e5e3 dd1b723 476e5e3 dd1b723 476e5e3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import { pipeline, TextStreamer } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.0';
class AppleChatbot {
constructor() {
this.generator = null;
this.isGenerating = false;
this.messages = [
{ role: "system", content: "You are a helpful and friendly assistant. Provide clear, concise, and accurate responses. Be
encouraging and positive in your interactions." }
];
this.initElements();
this.initEventListeners();
this.initWebWorker();
this.loadModel();
}
initElements() {
this.chatMessages = document.getElementById('chatMessages');
this.messageInput = document.getElementById('messageInput');
this.sendButton = document.getElementById('sendButton');
this.statusText = document.getElementById('statusText');
this.progressBar = document.getElementById('progressBar');
this.progressFill = document.getElementById('progressFill');
this.typingIndicator = document.getElementById('typingIndicator');
this.statusBar = document.getElementById('statusBar');
}
initEventListeners() {
this.sendButton.addEventListener('click', () => this.sendMessage());
this.messageInput.addEventListener('keydown', (e) => {
if (e.key |