Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] <title>LLM Generates Inconsistent and Mixed Content Types in Response </title> #1345

Open
TheChii opened this issue Jan 23, 2025 · 0 comments

Comments

@TheChii
Copy link

TheChii commented Jan 23, 2025

Description

When providing a specific prompt to the LLM, the response includes multiple types of content (JSON, XML, plain text, HTML, Markdown, and shell script) in a single output, which is not expected.

Steps to Reproduce

  1. Open the LLM interface.

  2. Provide the following prompt:
    document.addEventListener('DOMContentLoaded', () => {
    const editorContainer = document.querySelector('.editor-content');
    // Load tabs and editors from localStorage
    let tabsData = JSON.parse(localStorage.getItem('tabs')) || [
    { index: 0, content: '' }
    ];
    let tabIndex = tabsData.length - 1;

    function createNewTab() {
    tabIndex++;
    const newTab = document.createElement('button');
    newTab.className = 'tab';
    newTab.textContent = Tab ${tabIndex + 1};
    newTab.setAttribute('data-index', tabIndex);

     const addTabButton = document.querySelector('.add-tab');
     addTabButton.before(newTab);
    
     const newLineNumberContainer = document.createElement('div');
     newLineNumberContainer.className = 'line-numbers hidden';
     newLineNumberContainer.id = `lineNumbers${tabIndex}`;
     editorContainer.appendChild(newLineNumberContainer);
    
     const newCodeEditor = document.createElement('textarea');
     newCodeEditor.className = 'code-editor hidden';
     newCodeEditor.id = `codeEditor${tabIndex}`;
     newCodeEditor.placeholder = 'Start typing your code here...';
     editorContainer.appendChild(newCodeEditor);
    
     return { newTab, newLineNumberContainer, newCodeEditor };
    

    }

    function updateLineNumbers(index) {
    const editor = document.getElementById(codeEditor${index});
    const lines = editor.value.split('\n').length;
    let lineNumbersHTML = '';

     for (let i = 1; i <= lines; i++) {
         lineNumbersHTML += `<span>${i}</span><br>`;
     }
    
     document.getElementById(`lineNumbers${index}`).innerHTML = lineNumbersHTML;
    

    }

    function setActiveTab(tabIndex) {
    // Hide all editors and line numbers
    document.querySelectorAll('.code-editor').forEach(editor => editor.classList.add('hidden'));
    document.querySelectorAll('.line-numbers').forEach(lineNumbers => lineNumbers.classList.add('hidden'));

     // Show the selected editor and line numbers
     const activeEditor = document.getElementById(`codeEditor${tabIndex}`);
     const activeLineNumbers = document.getElementById(`lineNumbers${tabIndex}`);
    
     if (activeEditor && activeLineNumbers) {
         activeEditor.classList.remove('hidden');
         activeLineNumbers.classList.remove('hidden');
    
         // Update line numbers for the active editor
         updateLineNumbers(tabIndex);
     }
    
     // Update active tab styling
     document.querySelectorAll('.tab').forEach(tab => tab.classList.remove('active'));
     document.querySelector(`.tab[data-index="${tabIndex}"]`).classList.add('active');
    

    }

    document.querySelector('.tabs').addEventListener('click', (event) => {
    if (event.target.classList.contains('tab')) {
    const tabIndex = parseInt(event.target.getAttribute('data-index'), 10);
    setActiveTab(tabIndex);
    }
    });

    // Initial call to set up the first tab
    setActiveTab(tabsData[0].index);

    // Add new tab functionality
    const addTabButton = document.querySelector('.add-tab');
    addTabButton.addEventListener('click', () => {
    const { newTab, newLineNumberContainer, newCodeEditor } = createNewTab();

     // Set up event listeners for the new tab
     newTab.addEventListener('click', () => {
         const newIndex = parseInt(newTab.getAttribute('data-index'), 10);
         setActiveTab(newIndex);
     });
    
     newCodeEditor.addEventListener('input', () => {
         updateLineNumbers(tabIndex);
         saveTabsState();
     });
    
     // Activate the new tab immediately after adding it
     setActiveTab(tabIndex);
     saveTabsState();
    

    });

    // Run button functionality
    const runButton = document.querySelector('.run-button');
    runButton.addEventListener('click', () => {
    const activeTabIndex = parseInt(document.querySelector('.tab.active').getAttribute('data-index'), 10);
    const activeEditor = document.getElementById(codeEditor${activeTabIndex});
    const codeContent = activeEditor.value;

     try {
         // Open the code in a new browser tab
         const newTab = window.open();
         newTab.document.open();
         newTab.document.write(codeContent);
         newTab.document.close();
     } catch (error) {
         console.error("Error running code:", error);
     }
    

    });

    // Save tabs state on input change
    document.querySelectorAll('.code-editor').forEach(editor => {
    editor.addEventListener('input', () => {
    saveTabsState();
    });
    });

    // Save tabs state when the window is about to be unloaded
    window.addEventListener('beforeunload', () => {
    saveTabsState();
    });
    });

Expected Behavior

The LLM should generate a single, coherent response that matches the input prompt, such as a properly formatted JavaScript code snippet or an explanation related to the provided code.

Actual Behavior

The LLM generates a response that includes multiple types of content, such as:

json
y
{
"message": "Your JSON response has been successfully generated!",
"status": "success"
}
xml

Your XML response has been successfully generated! success Run HTML

Your plain text response has been successfully generated!
html

<title>Response</title>

Your HTML response has been successfully generated!

Run HTML markdown # Your Markdown response has been successfully generated! bash echo "Your shell script response has been successfully generated!"
@TheChii TheChii closed this as completed Jan 23, 2025
@TheChii TheChii changed the title [BUG] <title> Unrequested tasks? </title> [BUG] <title>LLM Generates Inconsistent and Mixed Content Types in Response </title> Jan 25, 2025
@TheChii TheChii reopened this Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant