It would still be illegal to ask the chatbot to recreate the text of Harry Potter.
Now, if you were to ask it to generate a similar story based on Harry Potter, that would be fine. Especially since that's basically what JK Rowling did after watching Star Wars.