A conversational chatbot backed by the Gemini API, with a deterministic rule-based local mode when no API key is present. Model id is configurable and defaults to gemini-2.0-flash.
- Thin
GeminiClientwrapper around thegenerateContentREST endpoint LocalResponderoffline fallback so the project runs and tests pass without any key or network- Interactive CLI and a Streamlit web app
- Model name configurable from the command line
pip install -r requirements.txt
GOOGLE_API_KEY=sk-your-key python -m chatbot_gemini_pro "tell me a fact"Without a key the CLI falls back to offline mode:
python -m chatbot_gemini_pro helloLive chat loop:
python -m chatbot_gemini_prostreamlit run app.pyThe app reads the key from Streamlit secrets (GOOGLE_API_KEY / GEMINI_API_KEY) or from the environment. When no key is found it clearly shows offline mode. Create .streamlit/secrets.toml locally if you want live answers.
from chatbot_gemini_pro import get_responder
bot = get_responder(api_key="sk-your-key") # or None for offline
print(bot.generate("hello"))python -m pytest -qAll tests exercise the offline fallback; live APIs are never called.
chatbot-gemini-pro/
chatbot_gemini_pro/
client.py
local.py
chat.py
__main__.py
app.py # Streamlit entry
tests/test_smoke.py
README.md
requirements.txt
.gitignore
MIT