Advanced Gemini-powered search with better grounding and citation control
Project description
GroundCite - AI-Powered Query Analysis Library
GroundCite is a Python library for adding better grounding and valid Citation support when searching using Gemini with google grounding . It combines web search using Gemini with google grounding with context validation, and structured data parsing using multiple AI providers to deliver accurate and reliable answers to complex questions.
๐ Features
Core Capabilities
- Graph-Based Pipeline: State-driven execution with automatic retry logic and error handling
- Web Search Integration: Intelligent web search with site filtering and content aggregation
- AI-Powered Validation: Optional content validation using advanced AI models
- Structured Data Parsing: Extract structured data using custom JSON schemas
- Comprehensive Logging: Detailed execution metrics and token usage tracking
Interface Options
- Command Line Interface (CLI): Feature-rich CLI with rich text formatting
- REST API: FastAPI-based web service for HTTP integration
- Python Library: Direct integration into Python applications
Advanced Features
- Retry Logic: Robust error handling with configurable retry mechanisms
- Token Usage Tracking: Monitor AI service consumption and costs
- Correlation Tracking: End-to-end request tracing and debugging
- Configuration Management: Flexible settings with validation
- Site Filtering: Include/exclude specific domains in search results
๐ Requirements
- Python: 3.12 or higher
- Dependencies: See requirements.txt for full list
Key Dependencies
langgraph- Graph-based workflow orchestrationgoogle-genai- Google Gemini AI integrationopenai- OpenAI API integrationfastapi- REST API frameworkclick- CLI frameworkrich- Enhanced terminal outputpydantic- Data validation and settings
๐ง Installation
From Source
git clone https://github.com/cennest/ground-cite.git
cd ground-cite/GroundCite
pip install -e .
Using pip (when published)
pip install gemini-groundcite
โก Quick Start
1. Basic CLI Usage
# Simple query analysis
gemini-groundcite analyze -q "What are the latest developments in AI?" --gemini-key your_gemini_key
# With validation and parsing
gemini-groundcite analyze -q "Company X financials" --validate --parse --gemini-key your_gemini_key
# Using OpenAI provider
gemini-groundcite analyze -q "Market trends" --provider openai --openai-key your_key --gemini-key your_gemini_key
2. Python Library Usage
from gemini_groundcite.config.settings import AppSettings
from gemini_groundcite.core.agents import AIAgent
# Configure settings
settings = AppSettings()
settings.ANALYSIS_CONFIG.query = "What are quantum computing breakthroughs?"
settings.ANALYSIS_CONFIG.validate = True
settings.ANALYSIS_CONFIG.parse = True
settings.AI_CONFIG.gemini_ai_key_primary = "your_gemini_key"
# Initialize and run analysis
agent = AIAgent(settings=settings)
results = await agent.analyze_query()
print(f"Analysis completed: {results['completed']}")
print(f"Results: {results['final_content']}")
3. REST API Usage
# Start the API server
python -m gemini_groundcite.main
# Make analysis requests
curl -X POST "http://localhost:8000/api/v1/analyze" \
-H "Content-Type: application/json" \
-d '{
"query": "Latest AI developments",
"config": {"validate": true, "parse": true},
"search_model_name": "gemini-2.5-flash",
"api_keys": {"gemini": {"primary": "your_key"}}
}'
๐๏ธ Architecture
GroundCite uses a sophisticated graph-based architecture that orchestrates multiple AI processing stages:
โโโโโโโโโโโโโโโโโโโ
โ Entry Point โ
โ โ
โ โโโโโโโโโโโโโโโ โ
โ โ CLI โ โ
โ โ Interface โ โ
โ โโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโ โ
โ โ REST API โ โ
โ โ (FastAPI) โ โ
โ โโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโ โ
โ โ Python Lib โ โ
โ โ Direct โ โ
โ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ AI Agent โ
โ Orchestrator โ
โ โ
โ โโโโโโโโโโโโโโโ โ
โ โ Graph โ โ
โ โ Executor โ โ
โ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Graph-Based Pipeline โ
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โOrchestrationโโโโโถโ Search โโโโโถโSearch Aggr. โ โ
โ โ Node โ โ Node โ โ Node โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โ โผ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ โ Validation โโโโโโValid. Aggr. โ โ
โ โ โ Node โ โ Node โ โ
โ โ โ (Optional) โ โ (Optional) โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โ โผ โ
โ โ โโโโโโโโโโโโโโโ โ
โ โ โ Parsing โ โ
โ โ โ Node โ โ
โ โ โ (Optional) โ โ
โ โ โโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโ โ โ
โ โ END โโโโโโโโโโโโโโโโโ โ
โ โ (Final) โ โ
โ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Core Components
1. AI Agent (gemini_groundcite.core.agents.AIAgent)
- Central orchestrator for query analysis
- Manages configuration and pipeline execution
2. Graph Executor (gemini_groundcite.core.executors.GraphExecutor)
- Implements the graph-based workflow using LangGraph
- Manages state transitions and node execution
- Handles concurrent operations and routing
3. Processing Nodes
- Orchestration Node: Controls overall execution flow
- Search Node: Performs web searches
- Search Aggregator: Consolidates search results
- Validation Node: AI-powered content validation
- Validation Aggregator: Processes validation results
- Parsing Node: Extracts structured data
4. AI Clients
- Google Gemini - Primary AI provider
- OpenAI - Alternative parsing provider
Data Flow
- Input: User query + configuration
- Search: Find relevant web content
- Validate: AI-powered content validation (if enabled)
- Parse: Extract structured data (if enabled)
- Output: Analysis results + metadata
Production Considerations
- Use environment variables for API keys
- Configure proper logging levels
- Set up monitoring and alerting
- Implement rate limiting
- Use database for configuration storage
- Set up load balancing for high traffic
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
# Clone the repository
git clone https://github.com/cennest/ground-cite.git
cd ground-cite/GroundCite
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support
- GitHub Issues: Report bugs and request features
- Documentation: Full documentation
- Email: anshulee@cennest.com
๐ Acknowledgments
- Built with LangGraph for workflow orchestration
- Powered by Google Gemini and OpenAI APIs
- CLI interface built with Click and Rich
- Web API built with FastAPI
GroundCite - Empowering intelligent query analysis with AI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gemini_groundcite-1.1.0.tar.gz.
File metadata
- Download URL: gemini_groundcite-1.1.0.tar.gz
- Upload date:
- Size: 59.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dd991325324f353f0ff0cde402534d72fb1ecb1a83183d97a66e8e6767f8dee
|
|
| MD5 |
c542bbb19ca92a7a2e7fb88a64445d99
|
|
| BLAKE2b-256 |
deb19d2749febf12f5f2b3af539c166e4adf83bd7490e976f7cc16f1c383d20a
|
File details
Details for the file gemini_groundcite-1.1.0-py3-none-any.whl.
File metadata
- Download URL: gemini_groundcite-1.1.0-py3-none-any.whl
- Upload date:
- Size: 74.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85b0c9d896eb4dbf0276cec2a0eb1f3ffa5757bd42dcd5b5fcf840b1b0ba13f9
|
|
| MD5 |
596c5700862ab3a2d20122ae7e4fcb30
|
|
| BLAKE2b-256 |
0592626398f74d5fc9d9bd372c2671119a913824da64453860d40d6bdf936297
|