This project is a chatbot web application built with FastAPI, HTML/CSS, and powered by the Google Gemini API using the OpenAI Python wrapper. It features session-based conversation tracking, persistent chat history, and a Clear Chat option to reset the conversation.
✅ FastAPI backend – lightweight & scalable
✅ Gemini API via OpenAI Wrapper – easy integration with Google’s AI
✅ Session management – each user has a unique session ID
✅ Persistent chat history – stored in store.txt
✅ Clear button – wipes all stored messages with one click
✅ Auto-scroll – always shows the latest message
✅ Clean UI – user messages (blue, right) & bot messages (grey, left)
You: Hello Bot!
Bot: Hi there 👋 How can I help you today?
User messages appear on the right (blue), and bot messages appear on the left (grey).
- Backend: FastAPI
- Frontend: HTML + CSS (vanilla)
- AI Model: Google Gemini API
- Wrapper: OpenAI Python SDK
- Persistence: File-based storage (
store.txt)
📦 gemini-chatbot
├── app.py # Main FastAPI app
├── store.txt # Stores all chat history
└── README.md # Project documentation
- Clone the repository
git clone https://github.com/yourusername/gemini-chatbot.git
cd gemini-chatbot- Install dependencies
pip install fastapi uvicorn openai-
Set up API Key Replace
"YOUR_API_KEY"inapp.pywith your actual Google Gemini API key. -
Run the app
uvicorn app:app --reload- Open in browser Go to 👉 http://127.0.0.1:8000
You: What is FastAPI?
Bot: FastAPI is a modern, fast web framework for building APIs with Python 3.7+.
Click the Clear Chat button to erase all stored history from store.txt.
This will reset the conversation for all sessions.
Contributions are welcome! Fork this repo and submit a pull request with improvements 🚀
✨ Built with ❤️ using FastAPI, Gemini API, and the OpenAI Wrapper ✨
Would you like me to also add screenshots/gif placeholders (like ) so it looks even more professional on GitHub?