An autonomous search assistant built for the command-line interface (CLI), designed to provide intelligent, up-to-date answers to user queries by leveraging web search and content extraction tools.
- Intelligent Agent: Uses LangChain agents with custom tools for web search and content fetching.
- Rich CLI Interface: Beautiful terminal UI with spinners, panels, and Markdown rendering using the Rich library.
- Real-time Feedback: Live updates during search and reading phases.
- Markdown Support: Answers rendered in Markdown format with proper citations.
- Source Tracking: Displays sources used for answers in an unordered list.
- Extensible Tools: Modular tool system for web operations.
CoNavic is built using a modular architecture with the following key components:
agent.py: Defines theAgentclass that orchestrates the conversation using LangChain's agent framework.cli.py: The main entry point providing the CLI interface with Rich-based UI elements.llm.py: Handles LLM interactions, supporting multiple providers (Cerebras, OpenAI).prompts.py: Contains system prompts and instructions for the agent and content extraction.utilis/tools.py: Implements custom tools for web search (web_search) and content fetching (web_fetch).
- User inputs a query via CLI.
- The agent processes the query, calling tools iteratively to gather information.
- Tools perform web searches or fetch content from URLs.
- Agent synthesizes information and generates a Markdown-formatted answer.
- CLI renders the answer with sources.
- web_search: Uses DuckDuckGo search API to find relevant web results.
- web_fetch: Extracts content from specified URLs using LLM-based summarization.
- Python 3.11 or higher
uvpackage manager (recommended) orpip
-
Clone the repository:
git clone https://github.com/mkantwala/CoNavic-CLI.git cd conavic -
Install dependencies:
uv sync
or
pip install -e . -
Activate the virtual environment:
uv run python
or
source .venv/bin/activate # On Unix .venv\Scripts\activate # On Windows
Create a .env file in the project root with the following environment variables:
CEREBAS_API_KEY=your_cerebras_api_key
CEREBAS_BASE_URL=https://api.cerebras.ai/v1
OPENAI_API_KEY=your_openai_api_key
OPENAI_API_BASE=https://api.openai.com/v1- CEREBAS_API_KEY and CEREBAS_BASE_URL: For the primary Reasonong LLM (Cerebras).
- OPENAI_API_KEY and OPENAI_API_BASE: For fallback or alternative LLM usage.
Run the CLI application:
python -m conavic.cliOr if using uv:
uv run python -m conavic.cliWelcome to CoNavic
██████╗ ██████╗ ███╗ ██╗ █████╗ ██╗ ██╗██╗ ██████╗
██╔════╝██╔═══██╗████╗ ██║██╔══██╗██║ ██║██║██╔════╝
██║ ██║ ██║██╔██╗ ██║███████║██║ ██║██║██║
██║ ██║ ██║██║╚██╗██║██╔══██║╚██╗ ██╔╝██║██║
╚██████╗╚██████╔╝██║ ╚████║██║ ██║ ╚████╔╝ ██║╚██████╗
╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═════╝
Your Autonomous search Assistant in your CLI
Ask Anything to search (or 'quit' to exit): current US president
🔍 Searching: current US president
⠸ Reading: En.wikipedia.org
⠸ Reading: Whitehouse.gov
ANSWER:
Donald J. Trump is the current President of the United States[Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States).
Sources:
- https://en.wikipedia.org/wiki/President_of_the_United_States
- https://www.whitehouse.gov/
conavic/
├── __init__.py
├── agent.py # Agent orchestration
├── cli.py # CLI interface
├── llm.py # LLM utilities
├── prompts.py # System prompts
└── utilis/
├── __init__.py
└── tools.py # Custom tools
Key dependencies include:
- langchain: For agent and tool orchestration
- langchain-openai: OpenAI LLM integration
- rich: Terminal UI and formatting
- ddgs: DuckDuckGo search API
- markitdown: Document processing
- python-dotenv: Environment variable management
- Define the tool function in
utilis/tools.pyusing the@tooldecorator. - Import and add it to the agent's tools list in
agent.py.
Modify llm.py to support additional providers or configurations.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License. See the LICENSE file for details.