Checking code: // basic hello greeting @GetMapping(“”) public String greeting() { return “Hello From Chatbot AI.”; } This is just testing if the basic Get from the AI Chatbot

Checking Code: // chat request mapping @GetMapping(“/chat”) public String chat(@RequestParam String message) { try { // user sends a message that is sent to chat gpt and a response is returned String response = getResponseFromAI(message); Chat chat = new Chat(message, response, new Date(System.currentTimeMillis()), 1l); Chat chatUpdated = chatJpaRepository.save(chat); System.out.println(“Chat saved in db: “ + chatUpdated.getId()); return response; } catch (Exception e) { e.printStackTrace(); return e.getMessage(); } }

Checking code: @DeleteMapping(“/chat/history/clear”) public String clearCharHistory() { List chats = chatJpaRepository.deleteByPersonId(1l); JSONObject obj = new JSONObject(); JSONArray list = new JSONArray();

	for (Chat c : chats) {
		System.out.println(c.getId());
		 list.add(c.toJSON());
	}
	
	obj.put("chats", list);
	return obj.toJSONString();
}

This is for clearing history

Checking code for: @GetMapping(“/chat/history”) public String getAllChatsForUser() { List chats = chatJpaRepository.findByPersonId(1l); JSONObject obj = new JSONObject(); JSONArray list = new JSONArray();

	for (Chat c : chats) {
		System.out.println(c.getId());
		 list.add(c.toJSON());
	}
	
	obj.put("chats", list);
	return obj.toString();
}

Reflection: All the code worked like last trimester with the review with the teacher