OvidijusParsiunas / deep-chat

Fully customizable AI chatbot component for your website
https://deepchat.dev
MIT License
1.43k stars 218 forks source link

VanillaJs example code console error message #90

Closed linqingfan closed 8 months ago

linqingfan commented 8 months ago

Screenshot from 2024-01-05 10-50-34

Hi, I copy and paste the live vanilla JS example (https://codesandbox.io/p/sandbox/deep-chat-vanillajs-v2ywnv) and it shows some syntax errors:

Uncaught SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse () at Object.object (deepChat.bundle.js:1:167115) at Hn.attributeChangedCallback (deepChat.bundle.js:1:101686) at deepChat.bundle.js:1:285588

The code run perfectly though.

OvidijusParsiunas commented 8 months ago

Hi @linqingfan.

I have tested this on my computer and it seems to work fine with no errors. Can you share the code you are using for this. Thankyou!

linqingfan commented 8 months ago

Hi @linqingfan.

I have tested this on my computer and it seems to work fine with no errors. Can you share the code you are using for this. Thankyou!

I just used the index.html in the link https://codesandbox.io/p/sandbox/deep-chat-vanillajs-v2ywnv

OvidijusParsiunas commented 8 months ago

Yep, that is the same code that I used and no error for me. I will test this out on another machine tomorrow.

Can I also ask, how are you hosting the file, do you run a server or is it just a plain index.html file viewed in the browser. Also, what kind of browser and operating system are you using, versions might be useful too. (Can you also try to update your browser or try others to see if the problem persists)

Final question, do you see any console errors (or the one that you have showed me) in the live example.

linqingfan commented 8 months ago

I just view it on my chrome browser on Windows 11, version 22H2 Yes, the errors are shown in the console. BTW, as mentioned in the first message, I only see the error messages in the chrome console. If I dont do F12, I wont be noticing any error messages and the program is still runnable.

BTW, on another issue, may I know if there is a way to change the conversation history when an event is activated. E.g. trying to omit the last character of the new message returned from the server.

chatElementRef.onNewMessage = (message) => { console.log(message); message.message.text = message.message.text.slice(0,-1) }; I understand this wont work with local var but I m trying to convey what my intention.

OvidijusParsiunas commented 8 months ago

I have tested the code on a Windows 11 - 22H2 machine with the latest Chrome Browser (version 120.0.6099.199 to date). I have additionally tested it on Ubuntu and Mac operating systems and once again I saw no errors in the console.

I will unfortunately have to conclude that this error is caused by the specific configuration that you have on your computer or your browser. If there is anything else that I can potentially do to replicate the error, please let me know, but because I cannot see it I am not be able to write a fix for it.

To answer your question for augmenting a response message, I would recommend checking out the responseInterceptor. If you need any specific assistance with this, please create a new issue so I can help there. Thanks!

linqingfan commented 8 months ago

Oh yes, when I tried the same code in Linux, there is no such error message. Should be windows environment....