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

Javascript Error in Reasoner v1 After Update to v3.7.0 #3421

Open
Harvester62 opened this issue Jan 26, 2025 · 5 comments
Open

Javascript Error in Reasoner v1 After Update to v3.7.0 #3421

Harvester62 opened this issue Jan 26, 2025 · 5 comments
Labels
bug-unconfirmed chat gpt4all-chat issues

Comments

@Harvester62
Copy link
Contributor

Harvester62 commented Jan 26, 2025

This issue might have the same root as this: #3419

Bug Report

After updating to version 3.7.0, I have noticed an issue with the Reasoner v1 when it attempts to use Javascript during its reasoning process. The model consistently returns an error whenever Javascript is involved. This issue did not occur in the previous release.

Additionally, in some cases, the Javascript reasoning process is triggered even after the model has already provided its final answer, which seems unintended.

Steps to Reproduce

  1. Use the Reasoner v1 with the chat template that comes with the model:

Image

  1. Provide the following user prompt (this comes from the previous version of GPT4All):

User: "Write code to check if a number is prime, use that to see if the number 7 is prime."

Assistant:
Certainly! Let's compute the answer to whether the number 7 is prime.

  1. Understand the task: The user wants me to write JavaScript code to determine if a given number (in this case, 7) is prime.
  2. Break down the problem:
    • Define a function isPrime(n) that checks if a number ( n ) is prime.
    • Use the function to check if 7 is prime.
  3. Write the code:
    function isPrime(n) {
        if (n <= 1) {
            return false;
        }
        for (let i = 2; i <= Math.sqrt(n); i++) {
            if (n % i === 0) {
                return false;
            }
        }
        return true;
    }
    
    const number = 7;
    console.log(`The number ${number} is prime: ${isPrime(number)}`);
  4. Compute the result:
function isPrime(n) {
    if (n <= 1) {
        return false;
    }
    for (let i = 2; i <= Math.sqrt(n); i++) {
        if (n % i === 0) {
            return false;
        }
    }
    return true;
}

const number = 7;
console.log(`The number ${number} is prime: ${isPrime(number)}`);

The number 7 is prime: true


This process demonstrates how I break down the task, write and interpret JavaScript code to solve it, and then present the final answer. If you have any more questions or need further assistance, feel free to ask! 


Now, observe the error generated in version 3.7.0: 

Certainly! Let's compute the answer to whether the number 7 is prime.
```javascript
function isPrime(n) {
    if (n <= 1) {
        return false;
    }
    for (let i = 2; i <= Math.sqrt(n); i++) {
        if (n % i === 0) {
            return false;
        }
    }
    return true;
}

const number = 7;
console.log(`The number ${number} is prime: ${isPrime(number)}`);

Uncaught exception at line 5: Error: console.log string formatting not supported
for (let i = 2; i <= Math.sqrt(n); i++) {```It looks like there was an error in the code. The console.log function does not support string formatting directly within it. Let's correct that and re-run the code.

Here is the corrected version:

function isPrime(n) {
    if (n <= 1) {
        return false;
    }
    for (let i = 2; i <= Math.sqrt(n); i++) {
        if (n % i === 0) {
            return false;
        }
    }
    return true;
}

const number = 7;
console.log('The number ' + number + ' is prime: ' + isPrime(number));

Uncaught exception at line 5: Error: console.log string formatting not supported
for (let i = 2; i <= Math.sqrt(n); i++) {```It seems there is a persistent issue with the console.log function not supporting string formatting directly. Let's try another approach by using template literals, which are supported in modern JavaScript environments.

Here is the corrected version:

function isPrime(n) {
    if (n <= 1) {
        return false;
    }
    for (let i = 2; i <= Math.sqrt(n); i++) {
        if (n % i === 0) {
            return false;
        }
    }
    return true;
}

const number = 7;
console.log(`The number ${number} is prime: ${isPrime(number)}`);

Uncaught exception at line 5: Error: console.log string formatting not supported
for (let i = 2; i <= Math.sqrt(n); i++) {```

Expected Behavior

I would hopefully expect that the Javascript processing works as it seemed to be happening before the last update. I don't know if the problem is in the code or in the model itself, but there is a difference of behavior compared to the previous version of the program.

Your Environment

  • GPT4All version: 3.7.0
  • Operating System: Windows 10
  • Chat model used (if applicable): Reasoner v1
@Harvester62 Harvester62 added bug-unconfirmed chat gpt4all-chat issues labels Jan 26, 2025
@PedzacyKapec
Copy link

Got the same problem.

@chancegray
Copy link

Looks like it may be related to this change: e2541a2

@chancegray
Copy link

I am not a developer but I asked the AI and it suggested:
Error Handling: The error handling in the JavaScript code might be too strict, as it throws an error if console.log is called with a string argument.

@chancegray
Copy link

chancegray commented Jan 30, 2025

It suggested the following code:

auto consoleObject = m_engine.evaluate(uR"(
    class Console {
        log(...args) {
            let cat = '';
            for (const arg of args) {
                cat += String(arg);
            }
            console_internal.log(cat);
        }
    }
    new Console();
)"_s);

@Lanchon
Copy link

Lanchon commented Jan 31, 2025

duplicate of #3419

EDIT: just 2 issues below it, lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed chat gpt4all-chat issues
Projects
None yet
Development

No branches or pull requests

4 participants