A command-line tool that answers questions by searching the web, analyzing content, and generating comprehensive answers with sources.
- Optimizes search queries using GPT-4
- Searches the web using DuckDuckGo
- Extracts clean content from web pages
- Analyzes content relevance using AI
- Generates detailed answers with sources
- Provides a summarized response
- Clone the repository:
git clone <repository-url>
cd askweb
- Install the package:
pip install .
Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY="your-api-key"
Basic usage:
askweb "Your question here"
With custom number of search results per query:
askweb --max-results 10 "Your question here"
askweb/
├── pyproject.toml # Project configuration and dependencies
├── .pre-commit-config.yaml # Pre-commit hooks configuration
├── src/
│ └── askweb/
│ ├── __init__.py
│ ├── cli.py # Command-line interface
│ ├── models.py # Pydantic data models
│ ├── search.py # Web search functionality
│ ├── content.py # Content extraction
│ ├── analysis.py # Content analysis
│ ├── openai_client.py # OpenAI API integration
│ └── prompts.py # Prompt templates
└── tests/
└── __init__.py
- click - Command-line interface
- openai: OpenAI API client
- duckduckgo_search: Web search functionality
- trafilatura: Web content extraction
- pydantic: Data validation and settings management
- rich: Terminal text formatting
- ruff - Python linter
MIT License - see LICENSE file for details.
To set up the development environment:
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -e ".[dev]"
- Run tests:
pytest
- Code formatting and linting:
# Format code
ruff format .
# Run isort
ruff check --select I --fix .
# Run linter
ruff check .
# Run linter with auto-fix
ruff check --fix .
This project uses Ruff for both code formatting and linting. The configuration follows these principles:
- Line length: 88 characters (same as Black)
- Python 3.12 target version
- Google-style docstrings
- Strict linting rules with select exceptions
- Automatic code formatting
To ensure your code meets the project standards:
- Format your code:
ruff format .
- Fix linting issues:
ruff check --fix .
- Address any remaining linting issues:
ruff check .