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] [Chat] failed TypeError: Cannot read properties of undefined (reading 'map') when switching between diff-brand Models in a Mask #5388

Closed
toanngoit opened this issue Sep 8, 2024 · 2 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@toanngoit
Copy link

toanngoit commented Sep 8, 2024

📦 Deployment Method

Official installation package

📌 Version

Sep 08, 2024

💻 Operating System

Windows

📌 System Version

Web version

🌐 Browser

Chrome

📌 Browser Version

Newest version on Sep 08, 2024

🐛 Bug Description

When using an existing Mask, switching among different Models
(e.g. switching from the current Google model to OpenAI model)
will throw an error in the JS Concolse and can't send the request to API.

The console message:
[Chat] failed TypeError: Cannot read properties of undefined (reading 'map')

How to fix the bug: See the Additional Information.

📷 Recurrence Steps

No response

🚦 Expected Behavior

We can make the API requests normally when switching between different brand Models on a Mask.

📝 Additional Information

How to fix the bug:

  • In the file: \app\store\plugin.ts

  • We can ensure the "ids" to be empty array if it is "undefined". i.e.

    getAsTools(ids: string[]) {
    if (!Array.isArray(ids)) {
    ids = []; // Fix bug: ensure ids as an empty array if undefined.
    }
    const plugins = get().plugins;
    const selected = ids
    .map((id) => plugins[id])
    .filter((i) => i)
    .map((p) => FunctionToolService.add(p));
    return [
    // @ts-ignore
    selected.reduce((s, i) => s.concat(i.tools), []),
    selected.reduce((s, i) => Object.assign(s, i.funcs), {}),
    ];
    },

@toanngoit toanngoit added the bug Something isn't working label Sep 8, 2024
@toanngoit toanngoit changed the title [Bug] [Chat] failed TypeError: Cannot read properties of undefined (reading 'map') [Bug] [Chat] failed TypeError: Cannot read properties of undefined (reading 'map') when switching between diff-brand Models in a Mask Sep 8, 2024
@lloydzhou lloydzhou added the duplicate This issue or pull request already exists label Sep 9, 2024
@lloydzhou
Copy link
Contributor

duplicate #5378

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


duplicate #5378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants