Skip to content

Added Gemini Chatbot CLI version with Google Generative AI integration #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gemini chatbot/Gemini-Chatbot
Submodule Gemini-Chatbot added at 9d3c59
24 changes: 24 additions & 0 deletions gemini chatbot/chatbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import google.generativeai as genai

genai.configure(api_key="GOOGLE_GEMINI_API_KEY")

model = genai.GenerativeModel("gemini-1.5-flash")

chat = model.start_chat(history=[])

def chat_with_gemini():
print("🤖 Gemini ChatBot (type 'exit' to quit)")
while True:
user_input = input("You: ")
if user_input.lower() in ["exit", "quit"]:
print("Bot: Goodbye 👋")
break

try:
response = chat.send_message(user_input)
print("Bot:", response.text)
except Exception as e:
print("⚠️ Error:", e)

if __name__ == "__main__":
chat_with_gemini()
19 changes: 19 additions & 0 deletions gemini chatbot/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---------------------------------------------- Gemini ChatBot 🤖 ----------------------------------------------

Welcome to the Gemini ChatBot Project — an intelligent, Python-based chatbot powered by Google’s Gemini 1.5 Flash model. This project allows you to have smart, interactive conversations directly in the terminal. It’s ideal for developers, students, or hobbyists exploring Generative AI and conversational interfaces. Whether you're curious about large language models or looking to contribute to open-source AI tools, this chatbot is a perfect place to start.

The Gemini ChatBot maintains conversation history, enabling more context-aware and meaningful interactions. It uses Google’s official Generative AI Python SDK to communicate with the Gemini API. The code is written for clarity and modularity, making it easy to customize, extend, and learn from.

To get started, you’ll need Python 3.8 to 3.10 installed on your machine (Python 3.13 may not be fully compatible yet) and an API key from Google AI Studio, which you can obtain for free. The chatbot is designed to run in a command-line environment and responds to your input in real-time, simulating a natural conversation. You can modify the script to integrate it into other platforms later, such as a web app or a GUI interface.

To ensure clean package management and avoid conflicts with other Python projects, it’s recommended to set up a Conda environment. Start by opening Anaconda Prompt or your terminal, then create a new environment with Python 3.10. Once the environment is created and activated, you can install the required google-generativeai package using pip. After that, you're ready to run the chatbot.

To launch the chatbot, navigate to the project folder in your terminal and run the Python script. The chatbot will start with a greeting and wait for your input. Simply type anything you’d like to ask or discuss. You can chat freely, and the model will respond with AI-generated replies. To end the session at any time, just type “exit” or “quit,” and the chatbot will close the conversation with a goodbye message.

The project folder is organized for simplicity and ease of use. The main script is chatbot.py, where all the chatbot logic is implemented. The requirements.txt file contains a list of dependencies, so others can easily replicate your environment using pip. A .gitignore file is included to exclude virtual environment folders and temporary files from version control.

Looking ahead, there are many exciting directions this project could take. You can add a web interface using Streamlit or Flask, implement support for file or image inputs using Gemini Pro Vision, enable chat logging to save previous conversations, or even integrate secure key storage using environment variables. These enhancements are perfect opportunities for open-source contributions.

If you’d like to contribute, you’re welcome to fork the repository, create your own feature branch, and submit a pull request. Feedback, improvements, and new ideas are encouraged — collaboration is at the heart of open-source.

Thank you for checking out the Gemini ChatBot! Whether you’re here to learn, experiment, or build, we hope this project helps you get one step closer to the future of AI-powered applications. Let’s build something incredible together. 🚀
1 change: 1 addition & 0 deletions gemini chatbot/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-generativeai>=0.3.2