Skip to content

feat: Add proxy support for Google Gemini API in MindsDB agents#1

Open
buallen wants to merge 3 commits into
mainfrom
feature/google-gemini-proxy-support
Open

feat: Add proxy support for Google Gemini API in MindsDB agents#1
buallen wants to merge 3 commits into
mainfrom
feature/google-gemini-proxy-support

Conversation

@buallen
Copy link
Copy Markdown
Owner

@buallen buallen commented Jul 3, 2025

🎯 Overview

This PR adds comprehensive proxy support for Google Gemini API integration in MindsDB agents, enabling the platform to work behind corporate firewalls and proxy networks.

🔧 Technical Changes

Google Gemini Handler (google_gemini_handler.py)

  • ✅ Added _configure_proxy() method for initialization-time proxy configuration
  • ✅ Added _configure_genai_with_proxy() method for runtime proxy configuration
  • ✅ Added _generate_content_with_proxy() method for direct REST API calls
  • ✅ Force REST transport instead of gRPC to support HTTP proxies
  • ✅ Support for HTTP_PROXY, HTTPS_PROXY, and ALL_PROXY environment variables

LangChain Agent (langchain_agent.py)

  • ✅ Added proxy configuration in LangchainAgent.__init__()
  • ✅ Enhanced create_chat_model() to configure proxy for Google provider
  • ✅ Force ChatGoogleGenerativeAI to use REST transport
  • ✅ Set proxy environment variables for requests library

🚀 Key Features

  • Automatic Proxy Detection: Reads proxy settings from environment variables
  • Fallback Mechanisms: Graceful degradation if proxy configuration fails
  • REST API Support: Direct REST calls with requests library for better proxy compatibility
  • Enterprise Ready: Works behind corporate firewalls and proxy networks
  • Backward Compatible: No breaking changes for existing installations

🧪 Testing

  • ✅ Tested with HTTP proxy on localhost:7890
  • ✅ Verified StoreHub business intelligence agent functionality
  • ✅ Confirmed successful Google Gemini API calls through proxy
  • ✅ Validated agent responses and data analysis capabilities

📊 Business Impact

This change enables MindsDB to be deployed in enterprise environments where:

  • Corporate firewalls block direct internet access
  • HTTP proxies are required for external API calls
  • Network security policies restrict gRPC traffic

🔍 Code Quality

  • Added comprehensive error handling and logging
  • Maintained existing API compatibility
  • Added fallback mechanisms for robustness
  • Clear separation of proxy configuration logic

📋 Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Functionality tested in proxy environment
  • No breaking changes introduced
  • Error handling implemented
  • Logging added for debugging

🎯 Related Issues

Fixes connectivity issues for MindsDB agents in proxy network environments.


Testing Environment: macOS with HTTP proxy (127.0.0.1:7890)
Agent Model: Google Gemini 2.0 Flash
Verification: StoreHub business analysis agent successfully analyzed 100+ business records


Pull Request opened by Augment Code with guidance from the PR author

buallen and others added 3 commits July 2, 2025 17:25
- Change default behavior to display all schemas instead of only public schema
- Particularly beneficial for data warehouses like Redshift, PostgreSQL, etc.
- Users can still explicitly set all_schemas=false to get old behavior
- Improves user experience by making all available data visible by default

Fixes issue where databases with multiple schemas appeared empty in the web UI
- Change default behavior to display all schemas instead of only public schema
- Particularly beneficial for data warehouses like Redshift, PostgreSQL, etc.
- Users can still explicitly set all_schemas=false to get old behavior
- Improves user experience by making all available data visible by default

Fixes issue where databases with multiple schemas appeared empty in the web UI
- Add comprehensive proxy configuration for Google Gemini handler
- Force REST transport instead of gRPC to support HTTP proxies
- Configure LangChain agents to use proxy for Google Gemini models
- Add fallback mechanisms for proxy configuration failures
- Enable MindsDB agents to work behind corporate firewalls

Key changes:
* GoogleGeminiHandler: Add _configure_proxy() and _configure_genai_with_proxy() methods
* LangchainAgent: Add proxy configuration in __init__ and create_chat_model()
* Support HTTP_PROXY, HTTPS_PROXY, and ALL_PROXY environment variables
* Use direct REST API calls with requests library for better proxy support

Fixes: Agent connectivity issues when running behind proxy networks
Tested: Successfully verified with StoreHub business intelligence agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant