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.
Harry Potter is a clone of Star Wars? I don't really see it, any more than any story that follows the Hero's Journey. I remember being a kid and reading Eragon though, and that really was very similar.
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.