Provides web search functionality for the Gemini Terminal Agent, handling concurrent requests and content extraction to deliver real-time information from the web.
A powerful terminal-based agent using Google's Gemini model with web search capabilities. This agent lets you interact with Gemini through your terminal while leveraging real-time web search for up-to-date information.
Clone the repository:
git clone https://github.com/yourusername/gemini-terminal-agent.git cd gemini-terminal-agent
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Create a .env
file in the project root with your API keys:
GOOGLE_GENAI_API_KEY=your_gemini_api_key_here
SEARCH_ENGINE_API_KEY=your_google_api_key_here
SEARCH_ENGINE_CSE_ID=your_cse_id_here
DEFAULT_MODEL=gemini-2.5-flash-preview-04-17
To use the web search functionality, you need to set up a Google Custom Search Engine:
Get a Google API Key:
SEARCH_ENGINE_API_KEY
)Create a Custom Search Engine:
*.com
to search the entire web)SEARCH_ENGINE_CSE_ID
)Get a Gemini API Key:
GOOGLE_GENAI_API_KEY
)Run the agent from the terminal:
python main.py
help
to see available tools and commandsclear
to clear the conversation historyexit
, quit
, or q
to exit the program>>> What is the capital of France?
Paris is the capital of France. It is located in the north-central part of the country on the Seine River.
>>> search for recent developments in quantum computing
Searching the web for recent developments in quantum computing...
[Agent response with up-to-date information]
>>> help
š Available Tools:
- search: Search for information online based on a query
- advanced_search: Perform an advanced search with domain filtering and time range options
āØļø Terminal Commands:
- help: Show this help message
- clear: Clear conversation history
- exit/quit/q: Exit the program
gemini-terminal-agent/
ā
āāā main.py # Main entry point
āāā search_server.py # Search server entry point
āāā .env # Environment variables (not versioned)
ā
āāā agent/ # Agent implementation
ā āāā __init__.py
ā āāā terminal_agent.py # Core agent implementation
ā āāā config.py # Agent configuration
ā
āāā search/ # Search functionality
ā āāā __init__.py
ā āāā server.py # MCP search server
ā āāā engine.py # Search engine implementation
ā āāā content.py # Web content extraction
ā
āāā utils/ # Shared utilities
āāā __init__.py
āāā config.py # Global configuration
āāā logging.py # Logging setup
You can customize the agent's behavior by modifying settings in your .env
file:
# Model settings
DEFAULT_MODEL=gemini-2.5-flash-preview-04-17
# Other models: gemini-1.5-pro, gemini-1.5-flash
# Search settings
MAX_CONCURRENT_REQUESTS=5
CONNECTION_TIMEOUT=10
CONTENT_TIMEOUT=15
MAX_CONTENT_LENGTH=5000
CACHE_TTL=3600
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!