A user is looking for a book to take with them on vacation. They're looking for a book about Greek Mythology, but doesn't know where to look. They open our book recommendation app which opens to a list of books they've marked read, then navigate to the recommendation forum page where they create a post describing the type of book they want. As they write the post, they enable the AI autorecommend feature to get an immediate response from an LLM. After posting, they browse through the AI's suggestions and add one that looks promising to their TBR list. A few hours later, they recieve a notification that another user replied with a book that seems like exactly what they want. The user checks out the two books from the library to take on vacation with them, happy that they were easily able to find a book they enjoyed.
The first test case just checks if posts are created and displayed correctly. It has 2 users make a post asking for recommendations, and one post gets 2 comments, one of which also gets a comment. The test was meant to make sure the tree-like structure of posts and comments were correctly stored and represented. It worked as expected and passed.
The second test involved a user asking for a recommendation and the LLM commenting with 3. It worked correctly for the most part, except sometimes the LLM would hallucinate and return a book.
The third test involved a post with a mix of user and LLM comments. It again tested the post and comments structure was correct but this one also tested to make sure the LLM didn't add a comment on a user comment, which is disallowed by the specification. Similar to the second test, this one was mostly successful, but the LLM would at times hallucinate books.
There are a variety of logical issues the LLM could produce. The most common one was it hallucinating books that didn't actually exist. To guard against this, a verifyBook method was included that used Google Books API to search the book the LLM gave to make sure the book was real. Since another API key is needed to make the requests, the method can't actually be used in the submitted version of this assignment, but it was still included with the call to it commented out. verifyBooks took in title and author of the recommended book, made a fetch request using these parameters, and checked that a valid book was returned. A second issue the LLM ran into was returning books without an author or without a title. To guard against this, the code checks that the LLM returned a JSON in the format requested with all of the necessary fields, title, author, and synopsis, filled with valid strings. A third issue is the LLM can return books that are only loosely related to what was requested and not exactly what users are looking for. Since this is subjective, I chose to have the comment the LLM produce also include a synopsis of the book and a list of categories that apply to it so that the user themselves can determine if it's a book similar enough to what they requested.