This repository contains a FastAPI-based application that integrates with Google's Generative AI (Gemini) model to create a conversational chatbot interface. Users can interact with the Gemini model by entering queries and receiving responses in real time.
- Generative AI Integration: Uses the
google.generativeailibrary to interact with the Gemini model. - Customizable Parameters: Configure model parameters such as
temperature,top_p,top_k, andmax_output_tokens. - Interactive Interface: Made with Vite based React, TypeScript and Tailwind.
- Python 3.X.
- Install required Python libraries:
pip install fastapi python-dotenv google-generativeai uvicorn
- Obtain a Gemini API key from Google AI.
Create a .env file in the root directory and add your Gemini API key:
GEMINI_API_KEY=your_api_key_here
-
Clone the repository:
git clone https://github.com/your-username/gemini-chatbot.git cd coffeebot -
Run the fastAPI backend:
uvicorn main:app --host 127.0.0.1 --port 8000
-
Open the provided URL in your browser to interact with the chatbot.
-
Open another terminal and change directory for frontend:
cd frontend
npm install # to setup frontend
npm run dev # to start frontend in development modeThe application allows customization of the model's generation configuration. Modify the following parameters in the code as needed:
temperature: Controls the randomness of the output.top_p: Sets the nucleus sampling threshold.top_k: Limits the number of candidate tokens considered at each step.max_output_tokens: Maximum number of tokens in the output.
- Start the application.
- Enter your question in the input box and click "Enter".
- View the AI response below the input box.
app.py: The main application file containing the chatbot logic..env: Environment file for storing Gemini API Key.
- Ensures the Gemini API key is provided. If missing, displays an error message and stops execution.
- Handles exceptions during model initialization or message processing, displaying user-friendly error messages.
Message
{
"message": "Hello, dear Coffee Bot"
}Response
{
"reply": "Hello there! How can I help you with your coffee needs today?\n"
}- There is no feature to save the chat history.
- Requires a valid Gemini API key to function.
Message and Response between Coffee Bot and the user

This project is open-source and available under the MIT License.
