Home > Back-end >  /n not working on JSON file to position text response for chatbot
/n not working on JSON file to position text response for chatbot

Time:04-11

so basically I'm trying to build a chatbot and I'm facing this problem as show in this picture

 {
        "tag": "Windows takes a long time to start",
        "patterns": ["Windows takes a long time to start"],
        "responses": ["1.Disable Fast Startup-open Settings and browse to System then click Power & sleep. \n On the right side of this screen, click Additional power settings to open the Power Options menu in the Control Panel and untick Turn on fast startup click Save.\n\n 2.Adjust Paging File Settings- Click Start Menu, choose the Adjust the appearance and performance of Windows. Under the Advanced tab, click Change. Uncheck Automatically manage paging file size for all drives then choose Custom Size and set the Initial Size and Maximum Size then Restart your computer.\n\n 3.Update Graphics Drivers- Open the Device Manager by right-clicking on the Start button (or hitting Win   X) and choose Device Manager. Go to Display adapters to see which graphics card you're using (others are Nvidia or AMD).Install any new version "]
    },

the json file could only handle one long sentence and I'm trying to find a way in which i could position the responses in multiple paragraphs or in bullet form since \n is not working. I'm sorry if this is a dumb question but I've been searching for days already but I can't still find the solution.

here's my github link btw for the full context of my code and my web-based chatbot

CodePudding user response:

You must add two slashes instead. In python, we can use '\n' to do line breaks and not '/n'. Notice that you asked why the forward slash does not work, well that is simply because you must use a backslash instead.

{
        "tag": "Windows takes a long time to start",
        "patterns": ["Windows takes a long time to start"],
        "responses": ["1.Disable Fast Startup-open Settings and browse to System then click Power & sleep. \\n On the right side of this screen, click Additional power settings to open the Power Options menu in the Control Panel and untick Turn on fast startup click Save.\\n\\n 2.Adjust Paging File Settings- Click Start Menu, choose the Adjust the appearance and performance of Windows. Under the Advanced tab, click Change. Uncheck Automatically manage paging file size for all drives then choose Custom Size and set the Initial Size and Maximum Size then Restart your computer.\\n\\n 3.Update Graphics Drivers- Open the Device Manager by right-clicking on the Start button (or hitting Win   X) and choose Device Manager. Go to Display adapters to see which graphics card you're using (others are Nvidia or AMD).Install any new version "]
    },

use:

# '\\n' for JSON and '\n' for Python

Hope this helps

CodePudding user response:

Found the solution. Using <br> solved the problem instead of \n, for the benefit of those who will also be facing the same problem.

  • Related