while True:
text = input(f"{Fore.GREEN}>> {Style.RESET_ALL}").strip()
if not text:
print(f"{Fore.RED}Enter valid text.{Style.RESET_ALL}")
continue
cmd = text.lower()
if cmd == "exit":
print(f"{Fore.BLUE}👋 Goodbye, Agent {name}!{Style.RESET_ALL}")
break
if cmd == "reset":
history.clear()
print(f"{Fore.CYAN}🧹 History cleared!{Style.RESET_ALL}")
continue
if cmd == "history":
if not history:
print(f"{Fore.YELLOW}No history yet.{Style.RESET_ALL}")
else:
for i, (t, p, s, c, e) in enumerate(history, 1):
print(f"{i}. {c}{e} {t} ({p:.2f}, {s}){Style.RESET_ALL}")
continue
p, s, c, e = sentiment_info(text)
history.append((text, p, s, c, e))
print(f"{c}{e} {s} sentiment detected! ({p:.2f}){Style.RESET_ALL}")
To embed this project on your website, copy the following code and paste it into your website's HTML: