Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chatbot-gemini-pro

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.

Features

  • Thin GeminiClient wrapper around the generateContent REST endpoint
  • LocalResponder offline 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

Quickstart

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 hello

Live chat loop:

python -m chatbot_gemini_pro

Streamlit app

streamlit run app.py

The 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.

Python API

from chatbot_gemini_pro import get_responder

bot = get_responder(api_key="sk-your-key")  # or None for offline
print(bot.generate("hello"))

Tests

python -m pytest -q

All tests exercise the offline fallback; live APIs are never called.

Project structure

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

License

MIT

About

Conversational chatbot backed by the Gemini API with a deterministic rule-based local mode when no key is present.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages