feat: implement comprehensive thinking modes and migrate to google-genai

Major improvements to thinking capabilities and API integration:

- Remove all output token limits for future-proof responses
- Add 5-level thinking mode system: minimal, low, medium, high, max
- Migrate from google-generativeai to google-genai library
- Implement native thinkingBudget support for Gemini 2.5 Pro
- Set medium thinking as default for all tools, max for think_deeper

🧠 Thinking Modes:
- minimal (128 tokens) - simple tasks
- low (2048 tokens) - basic reasoning
- medium (8192 tokens) - default for most tools
- high (16384 tokens) - complex analysis
- max (32768 tokens) - default for think_deeper

🔧 Technical Changes:
- Complete migration to google-genai>=1.19.0
- Remove google-generativeai dependency
- Add ThinkingConfig with thinking_budget parameter
- Update all tools to support thinking_mode parameter
- Comprehensive test suite with 37 passing unit tests
- CI-friendly testing (no API key required for unit tests)
- Live integration tests for API verification

🧪 Testing & CI:
- Add GitHub Actions workflow with multi-Python support
- Unit tests use mocks, no API key required
- Live integration tests optional with API key
- Contributing guide with development setup
- All tests pass without external dependencies

🐛 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Fahad
2025-06-09 09:35:21 +04:00
parent 9d45207d3f
commit fb5c04ea60
17 changed files with 813 additions and 171 deletions

View File

@@ -1,82 +1,87 @@
name: Test
name: Tests
on:
push:
branches: [ main ]
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12']
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -e .
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests with pytest
env:
GEMINI_API_KEY: "dummy-key-for-tests"
PYTHONPATH: ${{ github.workspace }}
- name: Run unit tests
run: |
python -m pytest tests/ -v --cov=gemini_server --cov-report=xml --cov-report=term -x
# Run all tests except live integration tests
# These tests use mocks and don't require API keys
python -m pytest tests/ --ignore=tests/test_live_integration.py -v --cov=. --cov-report=xml
env:
# Ensure no API key is accidentally used in CI
GEMINI_API_KEY: ""
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
fail_ci_if_error: true
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install flake8 black isort mypy
python -m pip install --upgrade pip
pip install ruff black
- name: Run black formatter check
run: black --check .
- name: Run ruff linter
run: ruff check .
live-tests:
runs-on: ubuntu-latest
# Only run live tests if API key secret is available
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && secrets.GEMINI_API_KEY != ''
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
- name: Run live integration tests
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 gemini_server.py --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
flake8 gemini_server.py --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
- name: Check formatting with black
run: |
black --check gemini_server.py
- name: Check import order with isort
run: |
isort --check-only gemini_server.py
- name: Type check with mypy
run: |
mypy gemini_server.py --ignore-missing-imports
# Run live tests that make actual API calls
python tests/test_live_integration.py
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}