anycoder-e18b332c / index.js
akhaliq's picture
akhaliq HF Staff
Upload index.js with huggingface_hub
476e5e3 verified
raw
history blame
1.13 kB
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