const MAX_CHARS = 500000; // Maximum character limit for context length
let totalMessages = 0; // Counter for total messages
let totalChars = 0; // Preserve total character counts
let totalWords = 0; // Preserve total word counts
let isSelectingText = false; // State flag to determine if text is selected
let overlay; // Overlay for actions
// Function to inject custom CSS styles
function injectStyles() {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://fonts.googleapis.com/css2?family=Cormorant+Garamond&display=swap';
document.head.appendChild(link);
const customStyles = `
* {
margin: 0 !important;
padding: 0 !important;
border: none !important;
box-shadow: none !important;
border-radius: 0 !important;
--chatbot-body-text-size: 20px !important;
color: #2c2a29 !important;
}
body, gradio-app, #col_container {
display: flex !important;
flex-direction: column !important;
flex-grow: 1 !important;
width: 100vw !important;
height: 100vh !important;
overflow: hidden !important;
color: #333 !important; /* Dark gray for better readability */
}
#col_container {
order: 1 !important;
width: 100% !important;
}
#component-7 {
order: 1 !important;
width: 100% !important;
display: flex !important;
justify-content: center !important;
opacity: 1 !important; /* Full opacity for clarity */
}
.form, #component-5 {
order: 2 !important;
width: 100% !important;
display: flex !important;
justify-content: center !important;
}
#chatbot {
order: 3 !important;
flex-grow: 1 !important;
display: flex !important;
flex-direction: column-reverse !important;
width: 100% !important;
overflow-y: auto !important;
height: 100% !important;
}
input, textarea {
width: 100% !important;
resize: none !important;
background: #1f1f1f !important; /* Dark gray/black background */
color: #ffffff !important; /* White text for contrast */
font-size: 18px !important;
border: 1px solid #444 !important; /* Darker gray border */
padding: 10px !important;
scrollbar-width: auto !important;
z-index: 1; /* Ensure it's above the background but below the overlay */
position: relative;
}
.input-overlay {
position: absolute;
inset: 0;
background: rgba(255, 255, 255, 0.5) !important; /* Slightly more transparent */
pointer-events: none; /* Allow interaction with the input field */
color: #000 !important; /* Black for overlay text */
display: flex;
justify-content: center;
align-items: center;
z-index: 0; /* Set below input */
transition: background 0.3s ease; /* Smooth background transition */
}
.input-overlay.hidden {
display: none; /* Control visibility */
}
div.svelte-sfqy0y {
overflow-y: visible !important;
}
.wrap.svelte-au1olv.svelte-au1olv {
display: none !important;
}
.message-row.user-row.svelte-1e1jlin {
align-self: flex-start !important;
}
#chatbot .user {
background: rgba(255, 223, 186, 1) !important; /* Soft light blue for user messages */
border: 1px solid rgba(108, 64, 40, 0.8) !important; /* Sky blue border */
color: #003366 !important; /* Darker blue text for better readability */
}
#chatbot .bot {
background: #FAEBD7 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"><defs><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.015" numOctaves="2" result="turbulence"/><feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/><feDiffuseLighting in="turbulence" lighting-color="%23FAEBD7"><feDistantLight azimuth="45" elevation="55"/></feDiffuseLighting></filter></defs><rect width="100%" height="100%" fill="%23FAEBD7" filter="url(%23noise)"/></svg>') repeat !important; color: #003300 !important;
}
#user_consent_container,
.svelte-1b6s6s,
.share-button,
.svelte-1gfkn6j,
footer,
.built-with,
#component-13,
.svelte-1eq475l,
#component-10,
#component-1,
#component-2 {
display: none !important;
}
.gradio-container {
max-width: 100% !important;
}
.gap.svelte-vt1mxs {
gap: 0 !important;
}
.message-row.bubble.bot-row.svelte-1e1jlin.svelte-1e1jlin.svelte-1e1jlin,
.user-row.bubble.svelte-1e1jlin.svelte-1e1jlin.svelte-1e1jlin {
max-width: 97vw !important;
}
.block.svelte-12cmxck {
background: none !important;
}
/* Status bar styles */
#statusBar {
position: fixed !important;
bottom: 10px !important;
right: 10px !important;
background: rgba(255, 223, 186, 0.5) !important; /* Light gray */
color: #030201 !important;
padding: 10px !important;
border-radius: 5px !important;
z-index: 10000 !important;
font-size: 14px !important;
pointer-events: none !important;
opacity: 0.8 !important;
}
/* Specific style for code blocks */
.gradio-container-4-44-0 .md pre {
background: none !important; /* No background */
border: 2px solid #ccc !important; /* 2px solid light gray border */
padding: 10px !important; /* Padding for visual separation */
margin: 10px 0 !important; /* Margin for spacing */
}
.gradio-container-4-44-0 .md :not(pre) > code {
border-radius: 4px !important; /* A standard radius */
white-space: normal !important;
background: rgba(240, 248, 255, 0.8) !important; /* Alice Blue */
border: 1px solid #ccc !important; /* Light gray */
padding: 4px 8px !important; /* Uniform padding */
}
/* Overlay styles */
.quote-overlay {
position: absolute;
background: rgba(0, 150, 255, 0.3); /* Light blue for visual separation */
border: 1px solid rgba(0, 150, 255, 1); /* Blue border */
border-radius: 5px; /* Rounded corners */
z-index: 10; /* Above all other elements */
display: flex;
flex-direction: column;
visibility: hidden;
}
.quote-button {
background: rgba(255, 255, 255, 0.8);
border: none;
padding: 2px 5px;
cursor: pointer;
font-size: 12px;
transition: background 0.3s ease;
margin: 2px; /* Spacing between buttons */
}
.quote-button:hover {
background: rgba(200, 200, 200, 0.8); /* Slightly darker on hover */
}
`;
const styleElement = document.createElement('style');
styleElement.textContent = customStyles;
document.head.appendChild(styleElement);
}
const sentenceStructures = [
["The %noun% %verb%",
"The %noun% %verb% %adverb%",
"The %adjective% %noun% %verb%",
"The %noun% is %adjective%",
"A %noun% %verb% at %noun%",
"%noun% often %verb% with %noun%",
"Every %adjective% %noun% %verb%",
"If %noun% can %verb%, surely %noun% will"],
["%noun% and %noun% are %adjective%",
"When %noun% %verb%, %noun% %verb%",
"%noun% and %noun% %verb% together",
"If %noun% can %verb%, then %noun% will %verb%",
"Neither %noun% nor %noun% dared to %verb%",
"Every %noun% %verb% before %noun%",
"%noun% and %noun% unite to %verb%",
"While %noun% %verb%, every %noun% watches"],
["%noun% %verb% under %noun%",
"Do you know why %noun% %verb%?",
"%noun% %verb% with %noun%",
"What would happen if %noun% %verb%?",
"%noun% quickly %verb% after %noun%",
"%noun% doesn't %verb% without %noun%",
"How can %noun% %verb% amidst %noun%?",
"While %noun% %verb%, %noun% whispers to %noun%"],
["In the %noun%, %noun% can %verb% elegantly",
"Because of the %adjective% %noun%, %noun% %verb%",
"The %noun% whispers %adverb% as it %verb%",
"Every %noun% seeks to %verb% during %noun%",
"Amidst the %noun%, a %adjective% %noun% %verb%",
"As fog envelops, %noun% %verb% silently",
"The %noun% and %noun% transform together",
"With a %adverb%, %noun% dances across %noun%"],
["Imagine a %adjective% %noun% %verb% across the %noun%",
"The %adverb% %noun% danced beneath the %noun%",
"%noun% gracefully leaped over the %noun%",
"As the %noun% %verb%, the %noun% begins to %verb%",
"A %noun% %verb% towards the %adjective% %noun%",
"In the stillness, %noun% might %verb% quietly",
"Between the %noun% and %noun%, %verb% is unspoken",
"Beneath a %noun%, a %noun% freely %verb%"],
["While the %noun% knows, the %noun% remains oblivious",
"Once the %noun% begins to %verb%, the %noun% transforms",
"Upon the %noun%, %noun% lays its %adjective% claim",
"Beyond the horizon, %noun% silently %verb% awaiting",
"During %noun%, %noun% seeks to %verb% forever",
"Against the %adjective% backdrop, %noun% %verb% fiercely",
"%noun% stays hidden until the %noun% %verb% loudly",
"%noun% thrives in the presence of %noun% during %noun%"],
["The %adjective% %noun% inspires the %noun% to %verb%",
"Underneath the stars, %noun% wishes to %verb% solemnly",
"Despite the %adjective% rain, %noun% assembles to %verb%",
"While clouds gather, %noun% continues to %verb% steadfastly",
"During twilight, the %noun% %verb% with elegance",
"What if a %noun% chose to %verb% instead of %verb?",
"Should %noun% ever dare to %verb%, %noun% would follow",
"Even through storms, a %noun% chose to %verb% unwaveringly"]
];
// Example parts of speech
const words = {
noun: ["cat", "dog", "rainbow", "sky", "elephant", "tiger", "computer", "love", "tree", "ocean",
"mountain", "car", "house", "book", "friend", "bird", "city", "music", "dream", "star",
"ball", "flower", "teacher", "chair", "road", "cloud", "moon", "fire", "beach", "garden",
"lake", "forest", "sun", "chocolate", "place", "food", "game", "planet", "dragon", "unicorn",
"proposal", "journey", "hero", "adventure", "idea", "schedule", "dance", "story", "airplane",
"universe", "time", "symphony", "happiness", "friendship", "pain", "secret", "goal", "challenge",
"reality", "truth", "fiction", "fantasy", "memory", "feeling", "wish", "soul", "quest",
"legend", "faith", "strategy", "trophy", "whistle", "honor", "wisdom", "hope", "gift",
"action", "winner", "champion", "concert", "river", "castle", "city", "sea", "hero",
"warrior", "sorcerer", "bird", "blossom", "sunrise", "spark", "whale", "oasis",
"dreamer", "sailor", "adventurer", "forest", "sunshine", "raindrop", "wave", "clover",
"island", "journey", "puzzle", "vision", "myth", "dragonfly", "butterfly", "dolphin",
"turtle", "computer", "robot", "fighter", "sword", "shield", "magic", "spell", "fantasy",
"kingdom", "cityscape", "landscape", "adventure", "throne", "explorer", "path", "boot",
"vehicle", "kite", "painting", "sculpture", "film", "show", "event", "celebration",
"festival", "gathering", "reunion", "moment", "memory", "story", "adventure", "journey",
"treasure", "fortune", "dreamland", "mystery", "secret", "discovery", "science",
"knowledge", "wisdom", "time", "history", "future", "present", "life", "situation",
"experience", "occurrence", "phenomenon", "event", "tale", "fable", "myth", "legend",
"invention", "creation", "innovation", "concept", "system", "network", "pathway",
"journey", "society", "culture", "tradition", "heritage", "legacy", "storyline",
"plot", "theme", "character", "protagonist", "antagonist", "arc", "chapter", "episode",
"volume", "series", "collection", "anthology", "library", "shelf", "bookcase",
"workspace", "studio", "lab", "office", "workspace", "arena", "court", "field",
"stadium", "platform", "zone", "location", "spot", "area", "region", "county"],
verb: ["sleeps", "jumps", "flies", "dances", "laughs", "runs", "swims", "writes", "creates", "builds",
"thinks", "dreams", "reads", "sings", "paints", "plays", "eats", "cooks", "travels", "explores",
"works", "teaches", "leads", "follows", "hugs", "kisses", "gives", "takes", "throws", "catches",
"skips", "whispers", "shouts", "drives", "draws", "looks", "feels", "hears", "sees",
"loves", "helps", "trains", "challenges", "fights", "stands", "sits", "waits", "believes",
"sets", "improvises", "gathers", "shares", "models", "acts", "reflects", "shapes",
"hops", "giggles", "stretches", "balances", "tumbles", "kicks", "runs", "jumps",
"dances", "sings", "paints", "teaches", "directs", "organizes", "arranges", "manages",
"designs", "produces", "envisions", "imagines", "conceptualizes", "innovates",
"collaborates", "negotiates", "facilitates", "communicates", "expresses", "emphasizes",
"describes", "illustrates", "demonstrates", "reflects", "adapts", "responds", "alters",
"transforms", "facilitates", "enables", "empowers", "motivates", "inspirits", "excites",
"drives", "propels", "accelerates", "continues", "persists", "endures", "overcomes",
"conquers", "achieves", "attains", "reaches", "realizes", "fulfills", "satisfies",
"captures", "entertains", "delights", "surprises", "astonishes", "impresses",
"stimulates", "challenges", "tests", "examines", "analyzes", "evaluates", "assesses",
"reviews", "compares", "contrasts", "critique", "breaks", "builds", "destroys",
"creates", "generates", "initiates", "starts", "launches", "fabricates", "constructs",
"develops", "designs", "solutions", "troubleshoots", "fixes", "corrects", "improves",
"enhances", "upgrades", "updates", "revises", "edits", "rewrites", "polishes",
"proofreads", "clarifies", "simplifies", "summarizes", "condenses", "compresses",
"translates", "interpret", "rephrase", "restate", "elucidates", "expounds",
"articulates", "conveys", "transmits", "relays", "broadcasts", "signals", "communicates",
"interacts", "engages", "communicates", "collaborates", "cooperates", "consents",
"partners", "joins", "unites", "merges", "integrates", "facilitates", "supports",
"advises", "recommends", "counsels", "mentors", "coaches", "trains", "educates",
"teaches", "enlightens", "informs", "lectures", "demonstrates", "exemplifies",
"illustrates", "models", "trains", "shapes", "molds", "forms", "guides", "directs",
"supervises", "oversees", "manages"],
adjective: ["happy", "sad", "colorful", "majestic", "bright", "dark", "beautiful", "ugly", "tall", "short",
"fast", "slow", "good", "bad", "funny", "serious", "calm", "exciting", "lovely", "boring",
"intelligent", "trained", "hungry", "angry", "joyful", "mysterious", "curious", "brave",
"fierce", "gentle", "smooth", "rough", "sweet", "sour", "rich", "poor", "kind",
"noble", "strong", "weak", "powerful", "fragile", "creative", "loyal", "friendly",
"hostile", "content", "adventurous", "trustworthy", "caring", "silly", "artistic",
"athletic", "tactile", "subtle", "bold", "innovative", "remarkable", "intimidating",
"mild", "fascinating", "classic", "modern", "timeless", "unique", "magical", "enigmatic",
"happy", "eager", "simple", "complex", "horrible", "wonderful", "brilliant",
"extraordinary", "ordinary", "diligent", "thoughtful", "thought-provoking", "beautiful",
"gorgeous", "stunning", "magnificent", "elegant", "graceful", "poignant", "sophisticated",
"charming", "captivating", "enchanting", "delicate", "robust", "dynamic", "energetic",
"enthusiastic", "passionate", "focused", "determined", "tenacious", "resilient",
"persevering", "tireless", "resourceful", "introspective", "reflective", "independent",
"affectionate", "generous", "compassionate", "sympathetic", "friendly", "gregarious",
"sociable", "courageous", "fearless", "audacious", "venturesome", "charismatic",
"dynamic", "vibrant", "zesty", "spicy", "joyful", "gleeful", "elated", "ecstatic",
"helpful", "supportive", "honest", "trustworthy", "reliable", "dependable",
"resourceful", "proactive", "motivated", "inspired", "aspirational", "innovative",
"cutting-edge", "futuristic", "visionary", "conventional", "traditional", "modernistic",
"artisanal", "handcrafted", "meticulous", "precision", "sustainable", "eco-friendly",
"innovative", "creative", "original", "novel", "groundbreaking", "revolutionary",
"game-changing", "impactful", "constructive", "positive", "enlightening", "thoughtful",
"mindful", "realistic", "practical", "idealistic", "triggering", "provocative",
"stimulating", "emotional", "rational", "logical", "constructive", "best", "worst"],
adverb: ["quickly", "silently", "beautifully", "eagerly", "happily", "sadly", "calmly", "creatively",
"intelligently", "gently", "confidently", "easily", "slowly", "enthusiastically",
"gracefully", "boldly", "bravely", "willingly", "elegantly", "mysteriously", "nervously",
"thoughtfully", "chirpily", "curiously", "cheerfully", "defiantly", "courageously",
"quietly", "frequently", "rarely", "seldom", "always", "never", "sometimes", "ordinarily",
"unstably", "positively", "greatly", "significantly", "notably", "deliberately", "neatly",
"assertively", "enthusiastically", "tirelessly", "fearlessly", "helpfully",
"meticulously", "warmly", "firmly", "eagerly", "freely", "gently", "passionately",
"playfully", "constructively", "understandingly", "compassionately", "openly",
"skillfully", "quickly", "smoothly", "elegantly", "dramatically", "intently",
"noisily", "silently", "brilliantly", "cleverly", "smartly", "strongly", "deeply",
"widely", "openly", "fearlessly", "apprehensively", "excitedly", "joyfully",
"enthusiastically", "frequently", "habitually", "occasionally", "infrequently",
"carefully", "cautiously", "generously", "humbly", "intensively", "actively",
"effectively", "efficiently", "strategically", "tactically", "creatively",
"artfully", "beautifully", "wonderfully", "naturally", "magically", "spontaneously",
"organically", "adaptively", "systematically", "logically", "methodically",
"creatively", "critically", "thoughtfully", "reflectively", "rapidly", "rapidly",
"suddenly", "unexpectedly", "punctually", "timely", "fondly", "nostalgically",
"cynically", "optimistically", "realistically", "ideally", "theoretically",
"practically", "ferociously", "fiercely", "dangerously", "safely", "calmly",
"delicately", "importantly", "notably", "infamously", "famously", "reliably",
"regularly", "randomly", "purposefully", "strategically", "intentionally",
"ridiculously", "humorously", "sarcastically", "streamlined", "automatically",
"technologically", "virtually", "realistically", "spiritually", "whimsically"],
};
// Function to generate a structured sentence based on selected structure
function generateStructuredSentence(tokens) {
const structure = sentenceStructures[tokens.length % sentenceStructures.length];
let selectedStructure = structure[0]; // Select the first structure for simplicity
// Replace placeholders with specific tokens or words
return selectedStructure.replace(/%(\w+)%/g, (match, key) => {
const wordList = words[key]; // Get the list of words for the matched key
return wordList[tokens[0]]; // Use the first token's corresponding word
});
}
// Function to update message counts
function updateMessageCounts() {
const messages = document.querySelectorAll('#chatbot .message-row');
totalChars = 0;
totalWords = 0;
messages.forEach((msg) => {
const text = msg.innerText || ''; // Get message text
totalChars += text.length; // Count characters
totalWords += countWords(text); // Count words accurately
});
totalMessages = messages.length; // Total messages count
updateStatusBar(totalChars, totalWords, totalMessages); // Update the display with new totals
}
// Function to accurately count words using regex
function countWords(text) {
const wordPattern = /\b(?:[A-Za-z0-9]+(?:[-'][A-Za-z0-9]+)*)\b/g; // Regex to match words
const matches = text.match(wordPattern);
return matches ? matches.length : 0; // Return number of matches or zero
}
// Function to update the status bar text and color
function updateStatusBar(charCount, wordCount, messageCount) {
const statusBar = document.getElementById('statusBar');
const percentage = (charCount / MAX_CHARS) * 100; // Calculate percentage based on characters
const color = `hsl(${(percentage > 100 ? 100 : percentage) * 1.2}, 100%, 50%)`; // Update color based on percentage
statusBar.innerText = `Chrs: ${charCount} | Wrds: ${wordCount} | Msgs: ${messageCount} | ${percentage.toFixed(2)}%`;
statusBar.style.color = color; // Update color of the status text
}
// Function to generate Fibonacci indices based on the total word count
function generateFibonacciIndices(length) {
let fib = [1, 1]; // Start with first two Fibonacci numbers
while (true) {
const nextFib = fib[fib.length - 1] + fib[fib.length - 2];
if (nextFib > length) {
break;
}
fib.push(nextFib); // Build the Fibonacci sequence
}
return fib;
}
// Function to create and initialize the status bar
function createStatusBar() {
const statusBar = document.createElement('div');
statusBar.id = 'statusBar';
document.body.appendChild(statusBar);
updateStatusBar(0, 0, 0); // Initialize with zero counters
const inputOverlay = document.createElement('div');
inputOverlay.classList.add('input-overlay', 'hidden');
const inputField = document.querySelector('input[type="text"], textarea');
if (inputField) {
inputField.parentNode.insertBefore(inputOverlay, inputField.nextSibling);
}
setInterval(() => {
if (!isSelectingText) {
updateMessageCounts(); // Only update if no selection is active
}
}, 300);
document.addEventListener('selectionchange', () => {
const selection = window.getSelection();
if (selection.toString() !== "") {
isSelectingText = true; // A text selection is active
const selectedChars = selection.toString().length;
const selectedWords = selectedChars > 0 ? selection.toString().trim().split(/\s+/).filter(word => word).length : 0;
// Update overlay with selected counts
updateStatusBar(selectedChars, selectedWords, totalMessages);
inputOverlay.classList.remove('hidden'); // Show overlay
showQuoteButton(); // Show quote button
} else {
inputOverlay.classList.add('hidden'); // Hide overlay if no selection
isSelectingText = false; // Mark text as not selected
// Return to total counts
updateStatusBar(totalChars, totalWords, totalMessages);
hideQuoteButton(); // Hide quote button
}
});
document.addEventListener('click', (event) => {
const selection = window.getSelection();
if (!selection.toString()) {
// If there's no selection, revert to total counts
updateStatusBar(totalChars, totalWords, totalMessages);
hideQuoteButton(); // Hide quote button
}
});
}
// Function to show overlay buttons upon text selection
function showQuoteButton() {
const selection = window.getSelection();
if (selection.rangeCount > 0) {
const range = selection.getRangeAt(0);
const rect = range.getBoundingClientRect();
// Create the overlay if it doesn't exist
if (!overlay) {
overlay = document.createElement('div');
overlay.classList.add('quote-overlay');
const quoteButton = document.createElement('button');
quoteButton.classList.add('quote-button');
quoteButton.innerText = 'Quote';
quoteButton.onclick = () => {
const textToQuote = selection.toString().trim();
const quotedText = `<code>"${textToQuote.replace(/"/g, '"')}"</code>\n`;
const inputField = document.querySelector('input[type="text"], textarea');
if (inputField) {
inputField.value += quotedText;
inputField.focus();
}
hideQuoteButton();
};
const randomQuoteButton = document.createElement('button');
randomQuoteButton.classList.add('quote-button');
randomQuoteButton.innerText = 'Random Quote (Fibonacci)';
randomQuoteButton.onclick = () => {
const allText = selection.toString().trim();
const words = allText.split(/\s+/); // Split selected text into words
const fibIndices = generateFibonacciIndices(words.length); // Generate Fibonacci indices
const maxOutputLength = Math.min(20000, words.length); // Use a reasonable max length based on number of words
let selectedOutput = [];
// Select words based on Fibonacci indices
fibIndices.forEach(index => {
if (selectedOutput.length < maxOutputLength && index < words.length) {
selectedOutput.push(words[index]);
}
});
// Generate the quoted text
const quotedText = `<code>Random Quote: "${selectedOutput.join(' ')}"</code>\n`;
const inputField = document.querySelector('input[type="text"], textarea');
if (inputField) {
inputField.value += quotedText;
inputField.focus();
}
hideQuoteButton();
};
overlay.appendChild(quoteButton);
overlay.appendChild(randomQuoteButton);
document.body.appendChild(overlay);
}
// Position the overlay according to the selected text
overlay.style.left = `${rect.right + window.scrollX + 5}px`; // 5px padding
overlay.style.top = `${rect.top + window.scrollY}px`; // Align overlay with selection
overlay.style.visibility = 'visible'; // Show overlay
}
}
// Function to hide the overlay
function hideQuoteButton() {
if (overlay) {
overlay.style.visibility = 'hidden'; // Hide the overlay
}
}
// Advanced Tokenizer Function
function advancedTokenizer(inputText) {
let sentencePattern = /([A-Z][^.!?]*[.!?])/g; // Capture full sentences
let wordPattern = /\w+/g; // Capture words
let sentences = inputText.match(sentencePattern); // Split text into sentences
let tokens = [];
for (let sentence of sentences) {
let words = sentence.match(wordPattern); // Tokenize individual sentences into words
if (words) {
tokens.push(words); // Store tokenized sentences
}
}
return tokens;
}
// Function to summarize content based on Fibonacci logic
function fibonacciSummarizer(inputText) {
let tokens = advancedTokenizer(inputText);
let fibIndices = generateFibonacciIndices(tokens.length); // Get Fibonacci indices
let summarySentences = [];
// Iterate over Fibonacci indices to build a summary
fibIndices.forEach(index => {
if (index < tokens.length) {
let selectedSentence = generateStructuredSentence(tokens[index]);
summarySentences.push(selectedSentence);
}
});
return summarySentences.join(" "); // Return the final summarized response
}
// Function to generate a structured sentence based on the selected structure
function generateStructuredSentence(token) {
const structure = sentenceStructures[token.length % sentenceStructures.length];
let selectedStructure = structure[0]; // Select the first structure for simplicity
// Replace placeholders with specific tokens or words
return selectedStructure.replace(/%(\w+)%/g, (match, key) => {
const wordList = words[key]; // Get the list of words for the matched key
return wordList[0]; // Use the first token's corresponding word for now
});
}
// Example usage of summarization
const exampleUserInput = "Purple elephants dance under spaghetti rainbows. Spaghetti rainbows can fly!";
const summary = fibonacciSummarizer(exampleUserInput);
console.log("Fibonacci Summary Output:", summary); // Output the summary to the console
// Initialize the styles and status bar upon script execution
createStatusBar();