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

I got an SyntaxError: JSON Parse error: Unexpected character: E #10

Open
zhouhao27 opened this issue Dec 7, 2024 · 1 comment
Open

Comments

@zhouhao27
Copy link

I got this error message:

SyntaxError: JSON Parse error: Unexpected character: E

In my line which is not related to this error at all.

Here is my source:

Create the OpenAI

const openAI = useMemo(() => new OpenAI({
    apiKey: 'sk-xxxxx,
    organization: 'ZH',
    host: 'https://myurl/v1',
  }), []);

Stream when button clicked

openAI.chat.stream({
      messages: [
        {
          role: 'user',
          content: message,
        },
      ],
      model: 'gpt-3.5-turbo',
    })

Add listener

useEffect(() => {
    const handleMessages = (payload: any) => {
      console.log('received message:', payload)
    };

    openAI.chat.addListener('onChatMessageReceived', handleMessages);

    return () => {
      openAI.chat.removeListener('onChatMessageReceived');
    }
  }, [openAI]);

I think the error happened somewhere in addListener. Because there is no error when I commented out openAI.chat.addListener.

Any idea? How to debug this issue? Thanks.

@gurbuzzomer
Copy link

@zhouhao27 did you solve the problem? Im getting the same error.

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

2 participants