This project is a simple chatbot that uses TF-IDF vectorization and cosine similarity to answer predefined questions related to Artificial Intelligence and Machine Learning. It now includes trivia and fact-sharing capabilities, as well as enhanced logging for interactions.
- Predefined Knowledge Base: Responds to questions about AI, machine learning, and related topics.
- Dynamic Content: Shares random trivia and facts about AI and technology.
- Interactive CLI: Provides a user-friendly command-line interface.
- Logging: Logs interactions to a CSV file for future analysis.
- Graceful Exit: Recognizes user input to end the conversation.
- Trivia and Fact Integration: Responds with random trivia or interesting AI-related facts.
- Enhanced Question Handling: Unrecognized questions now receive a clearer response guiding the user toward valid queries.
- Logging Support: All interactions are logged with timestamps in a CSV file.
- Python 3.10.x
- Required Libraries:
scikit-learn
: For TF-IDF and cosine similarity.time
: For simulated typing and logging timestamps.csv
: For interaction logging.sys
: For enhanced CLI interaction. Install dependencies:
pip install scikit-learn
-
Download the script file (
chatbot.py
). -
Navigate to the directory where the script is located.
-
Run the chatbot script using Python:
python chatbot.py
Chatbot: Ask me something.
User: What is AI?
Chatbot: Artificial Intelligence (AI) refers to machines or software designed to perform tasks that typically require human intelligence, such as decision-making, problem-solving, and language understanding.
Chatbot: Anything else?
User: Tell me a trivia.
Chatbot: ELIZA, one of the first chatbots, was created back in the 1960s.
Chatbot: Anything else?
User: Tell me a fact.
Chatbot: AI-powered language models like GPT-4o can generate human-quality text, write code, and translate languages.
Chatbot: Anything else?
User: What is quantum computing?
Chatbot: I do not have the answer you seek to that question. Try again with an AI-related question.
Chatbot: Anything else?
Chatbot: Anything else?
User: No
Chatbot: Goodbye!
All interactions are logged to a CSV file (e.g., log_YYYY-MM-DD_HH-MM-SS.csv
) with the following structure:
- Timestamp
- User Input
- Chatbot Response
- The chatbot is limited to its predefined knowledge base.
- Responses to unrelated questions may still not be entirely satisfactory.